// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react' import {IntlProvider} from 'react-intl' import { BrowserRouter as Router, Switch, Route, Redirect, } from 'react-router-dom' import client from './octoClient' import {IUser, UserContext} from './user' import {getCurrentLanguage, getMessages, storeLanguage} from './i18n' import {FlashMessages} from './components/flashMessages' import LoginPage from './pages/loginPage' import RegisterPage from './pages/registerPage' import BoardPage from './pages/boardPage' type State = { language: string, user: IUser|null, initialLoad: boolean, } export default class App extends React.PureComponent { constructor(props: unknown) { super(props) this.state = { language: getCurrentLanguage(), user: null, initialLoad: false, } } public componentDidMount(): void { client.getMe().then((user: IUser|null) => { this.setState({user, initialLoad: true}) }) } setAndStoreLanguage = (lang: string): void => { storeLanguage(lang) this.setState({language: lang}) } public render(): JSX.Element { return (
{this.state.initialLoad && !this.state.user && } {this.state.initialLoad && !this.state.user && }
) } }