diff --git a/apps/web/src/stores/user-store.js b/apps/web/src/stores/user-store.js index 33e89d79d..255881234 100644 --- a/apps/web/src/stores/user-store.js +++ b/apps/web/src/stores/user-store.js @@ -1,9 +1,12 @@ +import React from "react"; import createStore from "../common/store"; import { db } from "../common"; import { store as appStore } from "./app-store"; import BaseStore from "./index"; import config from "../utils/config"; import { EV } from "notes-core/common"; +import { showLoadingDialog } from "../components/dialogs/loadingdialog"; +import { Text } from "rebass"; class UserStore extends BaseStore { isLoggedIn = false; @@ -29,7 +32,7 @@ class UserStore extends BaseStore { }); }); EV.subscribe("db:sync", this.sync); - this.sync(); + await this.sync(); return true; }); }; @@ -39,7 +42,19 @@ class UserStore extends BaseStore { return db.user .login(form.username, form.password) .then(() => { - return this.init(); + return showLoadingDialog({ + title: "Importing your data...", + subtitle: + "We are importing your data from the server. Please wait...", + action: async () => { + return await this.init(); + }, + message: ( + + Please do NOT close your browser or power off your device. + + ), + }); }) .finally(() => { this.set((state) => (state.isLoggingIn = false)); @@ -63,7 +78,7 @@ class UserStore extends BaseStore { return db .sync() .then(() => { - appStore.refresh(); + return appStore.refresh(); }) .catch(async (err) => { if (err.code === "MERGE_CONFLICT") await appStore.refresh();