Move all firbase dependencies from actions layer to firebaseService layer (#13)
This commit is contained in:
@@ -1,101 +1,100 @@
|
||||
export interface IMasterProps{
|
||||
export interface IMasterProps {
|
||||
/**
|
||||
* Close gloal message
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
closeMessage: Function,
|
||||
closeMessage: Function,
|
||||
/**
|
||||
* Show progress bar information
|
||||
*
|
||||
*
|
||||
* @type {*}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
progress:any,
|
||||
progress: any,
|
||||
/**
|
||||
* Login a user
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
login: Function,
|
||||
login: Function,
|
||||
/**
|
||||
* Global state
|
||||
*
|
||||
*
|
||||
* @type {*}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
global:any,
|
||||
global: any,
|
||||
/**
|
||||
* Set flag {false} which user data has not loaded
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
defaultDataDisable: Function,
|
||||
defaultDataDisable: Function,
|
||||
/**
|
||||
* Logout current user
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
logout: Function,
|
||||
logout: Function,
|
||||
/**
|
||||
* Clear user date from store
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
clearData: Function,
|
||||
clearData: Function,
|
||||
/**
|
||||
* Prepare default data for a guest user
|
||||
*
|
||||
* Prepare default data for a guest user
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
loadDataGuest: Function,
|
||||
loadDataGuest: Function,
|
||||
/**
|
||||
* Set flag {true} which all user data has loaded
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
defaultDataEnable: Function,
|
||||
defaultDataEnable: Function,
|
||||
/**
|
||||
* Load user data into store
|
||||
*
|
||||
*
|
||||
* @type {Function}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
loadData: Function,
|
||||
loadData: Function,
|
||||
/**
|
||||
* If all data from all entities are loaded {true} if not {false}
|
||||
*
|
||||
*
|
||||
* @type {Boolean}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
loaded:Boolean,
|
||||
loaded: Boolean,
|
||||
/**
|
||||
* If current user is guest {true} if no
|
||||
*
|
||||
*
|
||||
* @type {Boolean}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
guest:Boolean,
|
||||
guest: Boolean,
|
||||
/**
|
||||
* If current user is authed {true} if not {false}
|
||||
*
|
||||
*
|
||||
* @type {Boolean}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
authed: Boolean,
|
||||
authed: Boolean,
|
||||
/**
|
||||
* Authed user identifier
|
||||
*
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof IMasterProps
|
||||
*/
|
||||
uid: string
|
||||
}
|
||||
|
||||
uid: string
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/// <reference types="@types/material-ui" />
|
||||
// - Import react components
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
@@ -33,7 +34,7 @@ import * as notifyActions from 'actions/notifyActions'
|
||||
/* ------------------------------------ */
|
||||
|
||||
// - Create Master component class
|
||||
export class Master extends Component<IMasterProps,IMasterState> {
|
||||
export class Master extends Component<IMasterProps, IMasterState> {
|
||||
|
||||
static isPrivate = true
|
||||
// Constructor
|
||||
@@ -108,45 +109,44 @@ export class Master extends Component<IMasterProps,IMasterState> {
|
||||
*/
|
||||
public render (): React.ReactElement<{}> {
|
||||
|
||||
const {progress, global} = this.props
|
||||
const { progress, global } = this.props
|
||||
|
||||
return (
|
||||
<div id='master'>
|
||||
|
||||
<div className='master__progress' style={{display: (progress.visible ? 'block' : 'none' )}}>
|
||||
<LinearProgress mode='determinate' value={progress.percent} />
|
||||
</div>
|
||||
<div className='master__loading animate-fading2' style={{display: ( global.showTopLoading ? 'flex' : 'none' )}}>
|
||||
<div className='title'>Loading ... </div>
|
||||
</div>
|
||||
<div className='master__progress' style={{ display: (progress.visible ? 'block' : 'none') }}>
|
||||
<LinearProgress mode='determinate' value={progress.percent} />
|
||||
</div>
|
||||
<div className='master__loading animate-fading2' style={{ display: (global.showTopLoading ? 'flex' : 'none') }}>
|
||||
<div className='title'>Loading ... </div>
|
||||
</div>
|
||||
<MasterLoading activeLoading={this.state.loading || !(this.props.loaded || this.props.guest)} handleLoading={this.handleLoading} />
|
||||
|
||||
{(!this.state.loading && (this.props.loaded || this.props.guest))
|
||||
? (<Switch>
|
||||
<Route path='/signup' component={Signup} />
|
||||
<Route path='/settings' component={Settings} />
|
||||
<Route path='/login' render={() => {
|
||||
console.log('this.props.authed: ', this.props.authed, 'this.props: ', this.props)
|
||||
return (
|
||||
this.props.authed
|
||||
? <Redirect to='/' />
|
||||
: <Login />
|
||||
)
|
||||
}
|
||||
} />
|
||||
<Route render={() => <Home uid={this.props.uid}/>} />
|
||||
? (<Switch>
|
||||
<Route path='/signup' component={Signup} />
|
||||
<Route path='/settings' component={Settings} />
|
||||
<Route path='/login' render={() => {
|
||||
console.log('this.props.authed: ', this.props.authed, 'this.props: ', this.props)
|
||||
return (
|
||||
this.props.authed
|
||||
? <Redirect to='/' />
|
||||
: <Login />
|
||||
)
|
||||
}
|
||||
} />
|
||||
<Route render={() => <Home uid={this.props.uid} />} />
|
||||
|
||||
</Switch>) : ''
|
||||
</Switch>) : ''
|
||||
}
|
||||
<Snackbar
|
||||
open={this.props.global.messageOpen}
|
||||
message={this.props.global.message}
|
||||
autoHideDuration={4000}
|
||||
style={{left: '1%', transform: 'none'}}
|
||||
style={{ left: '1%', transform: 'none' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -157,11 +157,11 @@ const mapDispatchToProps = (dispatch: any, ownProps: any) => {
|
||||
return {
|
||||
loadData: () => {
|
||||
dispatch(commentActions.dbGetComments())
|
||||
dispatch(imageGalleryActions.downloadForImageGallery())
|
||||
dispatch(imageGalleryActions.dbGetImageGallery())
|
||||
dispatch(postActions.dbGetPosts())
|
||||
dispatch(userActions.dbGetUserInfo())
|
||||
dispatch(voteActions.dbGetVotes())
|
||||
dispatch(notifyActions.dbGetNotifies())
|
||||
dispatch(notifyActions.dbGetNotifications())
|
||||
dispatch(circleActions.dbGetCircles())
|
||||
|
||||
},
|
||||
@@ -202,7 +202,7 @@ const mapDispatchToProps = (dispatch: any, ownProps: any) => {
|
||||
* @param {object} state
|
||||
*/
|
||||
const mapStateToProps = (state: any) => {
|
||||
const {authorize, global, user, post, comment, imageGallery , vote, notify,circle } = state
|
||||
const { authorize, global, user, post, comment, imageGallery, vote, notify, circle } = state
|
||||
return {
|
||||
guest: authorize.guest,
|
||||
uid: authorize.uid,
|
||||
|
||||
Reference in New Issue
Block a user