dont show ui before initial sync

This commit is contained in:
Bruno Windels 2019-02-27 23:38:03 +01:00
parent 8f09fdbc79
commit 818cf8051c

View file

@ -54,14 +54,19 @@ export default async function main(label, button, container) {
await session.setLoginData(loginData); await session.setLoginData(loginData);
} }
await session.load(); await session.load();
showSession(container, session); const hsApi = new HomeServerApi(HOMESERVER, session.accessToken);
const hsApi = new HomeServerApi(HOMESERVER, session.accessToken); console.log("session loaded");
console.log("session loaded"); const needsInitialSync = !session.syncToken;
if (!session.syncToken) { if (needsInitialSync) {
console.log("session needs initial sync"); console.log("session needs initial sync");
} } else {
showSession(container, session);
}
const sync = new Sync(hsApi, session, storage); const sync = new Sync(hsApi, session, storage);
await sync.start(); await sync.start();
if (needsInitialSync) {
showSession(container, session);
}
label.innerText = "sync running"; label.innerText = "sync running";
button.addEventListener("click", () => sync.stop()); button.addEventListener("click", () => sync.stop());
sync.on("error", err => { sync.on("error", err => {