// - Import react components import React, { Component } from 'react' import { connect } from 'react-redux' import { Route, Switch, NavLink, withRouter, Redirect } from 'react-router-dom' import { firebaseAuth, firebaseRef } from 'app/firebase/' import { push } from 'react-router-redux' import Snackbar from 'material-ui/Snackbar'; import LinearProgress from 'material-ui/LinearProgress' // - Import components import Home from 'Home' import Signup from 'Signup' import Login from 'Login' import Settings from 'Settings' import MasterLoading from 'MasterLoading' // - Import API import { PrivateRoute, PublicRoute } from 'AuthRouterAPI' // - Import actions import * as authorizeActions from 'authorizeActions' import * as imageGalleryActions from 'imageGalleryActions' import * as postActions from 'postActions' import * as commentActions from 'commentActions' import * as voteActions from 'voteActions' import * as userActions from 'userActions' import * as globalActions from 'globalActions' import * as circleActions from 'circleActions' import * as notifyActions from 'notifyActions' /* ------------------------------------ */ // - Create Master component class export class Master extends Component { static isPrivate = true // Constructor constructor(props) { super(props); this.state = { loading: true, authed: false, dataLoaded: false }; // Binding functions to `this` this.handleLoading = this.handleLoading.bind(this) this.handleMessage = this.handleMessage.bind(this) } // Handle click on message handleMessage = (evt) => { this.props.closeMessage() } // Handle loading handleLoading = (status) => { this.setState({ loading: status, authed: false }) } componentWillMount = () => { firebaseAuth().onAuthStateChanged((user) => { if (user) { this.props.login(user) this.setState({ loading: false }) if (!this.props.global.defaultLoadDataStatus) { this.props.clearData() this.props.loadData() this.props.defaultDataEnable() } } else { this.props.logout() this.setState({ loading: false }) if (this.props.global.defaultLoadDataStatus) { this.props.defaultDataDisable() this.props.clearData() } this.props.loadDataGuest() } }) } /** * Render app DOM component * * @returns * * @memberof Master */ render() { const {progress, global} = this.props return (