// 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 { List, Map } from "immutable"; import { routeResolver } from "./App"; import AppBarOverride from "./widgets/AppBarOverride"; import LoadingIndicator from "./widgets/LoadingIndicator"; import ContactsMain from "./Contacts/Main"; import Journals from "./Journals"; import Settings from "./Settings"; import Debug from "./Debug"; import * as EteSync from "etesync"; import { SyncManager } from "./sync/SyncManager"; import { StoreState } from "./store"; import { performSync } from "./store/actions"; import { useCredentials } from "./credentials"; export interface SyncInfoJournal { journal: EteSync.Journal; journalEntries: List; collection: EteSync.CollectionInfo; entries: List; } export type SyncInfo = Map; export default function SyncGate() { const etebase = useCredentials(); const settings = useSelector((state: StoreState) => state.settings); const userInfo = useSelector((state: StoreState) => state.cache.userInfo); const journals = useSelector((state: StoreState) => state.cache.journals); 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); // FIXME: remove const etesync = etebase as any; return ( ( )} /> events tasks {false && ( <> ( )} /> )} ( )} /> ( )} /> ); }