2020-06-27 12:02:54 +01:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import { LoadingMessage } from "./LoadingMessage";
|
2021-01-04 02:21:52 +05:30
|
|
|
import {
|
|
|
|
defaultLang,
|
|
|
|
Language,
|
|
|
|
languages,
|
|
|
|
setLanguageFirstTime,
|
|
|
|
} from "../i18n";
|
2020-06-27 12:02:54 +01:00
|
|
|
|
2021-01-04 02:21:52 +05:30
|
|
|
interface Props {
|
|
|
|
langCode: Language["code"];
|
|
|
|
}
|
|
|
|
interface State {
|
|
|
|
isLoading: boolean;
|
|
|
|
}
|
|
|
|
export class InitializeApp extends React.Component<Props, State> {
|
2020-06-27 12:02:54 +01:00
|
|
|
public state: { isLoading: boolean } = {
|
|
|
|
isLoading: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
async componentDidMount() {
|
2021-01-04 02:21:52 +05:30
|
|
|
const currentLang =
|
|
|
|
languages.find((lang) => lang.code === this.props.langCode) ||
|
|
|
|
defaultLang;
|
|
|
|
await setLanguageFirstTime(currentLang);
|
2020-06-27 12:02:54 +01:00
|
|
|
this.setState({
|
|
|
|
isLoading: false,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public render() {
|
|
|
|
return this.state.isLoading ? <LoadingMessage /> : this.props.children;
|
|
|
|
}
|
|
|
|
}
|