// SPDX-FileCopyrightText: © 2017 EteSync Authors // SPDX-License-Identifier: AGPL-3.0-only import * as React from "react"; import { useSelector, useDispatch } from "react-redux"; import { Route, Switch, Redirect, useHistory } from "react-router"; import moment from "moment"; import "moment/locale/en-gb"; import { routeResolver } from "./App"; import AppBarOverride from "./widgets/AppBarOverride"; import LoadingIndicator from "./widgets/LoadingIndicator"; import Container from "./widgets/Container"; import ContactsMain from "./Contacts/Main"; import CalendarsMain from "./Calendars/Main"; import TasksMain from "./Tasks/Main"; import CollectionsMain from "./Collections/Main"; import Settings from "./Settings"; import Debug from "./Debug"; import { SyncManager } from "./sync/SyncManager"; import { StoreState } from "./store"; import { performSync } from "./store/actions"; import { useCredentials } from "./credentials"; import PimNavigationTabs from "./Pim/NavigationTabs"; import { PageNotFoundRoute } from "./PageNotFound"; export default function SyncGate() { const etebase = useCredentials(); const settings = useSelector((state: StoreState) => state.settings); const dispatch = useDispatch(); const [loading, setLoading] = React.useState(true); // Doing this so we refresh on route changes useHistory(); React.useEffect(() => { (async () => { const syncManager = SyncManager.getManager(etebase!); const sync = syncManager.sync(); dispatch(performSync(sync)); await sync; setLoading(false); })(); }, []); if (loading) { return (); } // FIXME: Shouldn't be here moment.locale(settings.locale); return ( ( )} /> ( )} /> ( )} /> ); }