2019-03-25 20:53:33 +01:00
|
|
|
import React, { Component } from 'react';
|
2019-03-30 22:13:49 +01:00
|
|
|
import {MuiThemeProvider, CssBaseline, withStyles } from '@material-ui/core';
|
2019-03-27 22:39:25 +01:00
|
|
|
import { setHyperspaceTheme, darkMode } from './utilities/themes';
|
2019-03-26 02:37:02 +01:00
|
|
|
import AppLayout from './components/AppLayout';
|
|
|
|
import {styles} from './App.styles';
|
2019-04-21 22:50:23 +02:00
|
|
|
import {Route} from 'react-router-dom';
|
2019-03-27 22:39:25 +01:00
|
|
|
import AboutPage from './pages/About';
|
|
|
|
import Settings from './pages/Settings';
|
|
|
|
import { getUserDefaultBool, getUserDefaultTheme } from './utilities/settings';
|
2019-03-28 21:46:19 +01:00
|
|
|
import ProfilePage from './pages/ProfilePage';
|
2019-03-30 22:13:49 +01:00
|
|
|
import HomePage from './pages/Home';
|
2019-03-31 03:20:55 +02:00
|
|
|
import LocalPage from './pages/Local';
|
|
|
|
import PublicPage from './pages/Public';
|
2019-04-01 03:56:41 +02:00
|
|
|
import Conversation from './pages/Conversation';
|
2019-03-31 22:49:09 +02:00
|
|
|
import NotificationsPage from './pages/Notifications';
|
2019-04-02 23:28:04 +02:00
|
|
|
import SearchPage from './pages/Search';
|
2019-04-04 02:01:54 +02:00
|
|
|
import Composer from './pages/Compose';
|
2019-04-07 23:25:39 +02:00
|
|
|
import WelcomePage from './pages/Welcome';
|
2019-04-08 00:22:39 +02:00
|
|
|
import MessagesPage from './pages/Messages';
|
2019-04-21 19:45:47 +02:00
|
|
|
import RecommendationsPage from './pages/Recommendations';
|
2019-04-21 22:14:03 +02:00
|
|
|
import Missingno from './pages/Missingno';
|
2019-03-30 22:13:49 +01:00
|
|
|
import {withSnackbar} from 'notistack';
|
2019-04-07 23:25:39 +02:00
|
|
|
import {PrivateRoute} from './interfaces/overrides';
|
2019-04-08 00:22:39 +02:00
|
|
|
import { userLoggedIn } from './utilities/accounts';
|
2019-03-27 22:39:25 +01:00
|
|
|
let theme = setHyperspaceTheme(getUserDefaultTheme());
|
2019-03-28 00:24:52 +01:00
|
|
|
|
2019-03-25 22:01:39 +01:00
|
|
|
class App extends Component<any, any> {
|
2019-03-26 02:37:02 +01:00
|
|
|
|
2019-03-30 22:13:49 +01:00
|
|
|
offline: any;
|
|
|
|
|
2019-03-27 22:39:25 +01:00
|
|
|
constructor(props: any) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
|
|
|
theme: theme
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillMount() {
|
|
|
|
let newTheme = darkMode(this.state.theme, getUserDefaultBool('darkModeEnabled'));
|
|
|
|
this.setState({ theme: newTheme });
|
|
|
|
}
|
|
|
|
|
2019-03-25 20:53:33 +01:00
|
|
|
render() {
|
2019-03-25 22:01:39 +01:00
|
|
|
const { classes } = this.props;
|
2019-03-30 22:13:49 +01:00
|
|
|
|
2019-03-25 20:53:33 +01:00
|
|
|
return (
|
2019-03-27 22:39:25 +01:00
|
|
|
<MuiThemeProvider theme={this.state.theme}>
|
2019-03-26 02:37:02 +01:00
|
|
|
<CssBaseline/>
|
2019-04-07 23:25:39 +02:00
|
|
|
<Route path="/welcome" component={WelcomePage}/>
|
|
|
|
<div>
|
|
|
|
{ userLoggedIn()? <AppLayout/>: null}
|
2019-04-21 22:50:23 +02:00
|
|
|
<PrivateRoute exact path="/" component={HomePage}/>
|
|
|
|
<PrivateRoute path="/home" component={HomePage}/>
|
|
|
|
<PrivateRoute path="/local" component={LocalPage}/>
|
|
|
|
<PrivateRoute path="/public" component={PublicPage}/>
|
|
|
|
<PrivateRoute path="/messages" component={MessagesPage}/>
|
|
|
|
<PrivateRoute path="/notifications" component={NotificationsPage}/>
|
|
|
|
<PrivateRoute path="/profile/:profileId" component={ProfilePage}/>
|
|
|
|
<PrivateRoute path="/conversation/:conversationId" component={Conversation}/>
|
|
|
|
<PrivateRoute path="/search" component={SearchPage}/>
|
|
|
|
<PrivateRoute path="/settings" component={Settings}/>
|
|
|
|
<PrivateRoute path="/about" component={AboutPage}/>
|
|
|
|
<PrivateRoute path="/compose" component={Composer}/>
|
|
|
|
<PrivateRoute path="/recommended" component={RecommendationsPage}/>
|
2019-04-07 23:25:39 +02:00
|
|
|
</div>
|
|
|
|
|
2019-03-25 22:01:39 +01:00
|
|
|
</MuiThemeProvider>
|
2019-03-25 20:53:33 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-30 22:13:49 +01:00
|
|
|
export default withStyles(styles)(withSnackbar(App));
|