Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: show loading dialog when importing backup

thecodrr06c8637980dd
diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.js
index 07797c67c..ec511743f 100644
--- a/apps/web/src/components/dialogs/confirm.js
+++ b/apps/web/src/components/dialogs/confirm.js
@@ -72,8 +72,7 @@ export function showMultiDeleteConfirmation(type) {
let noun = type === "note" ? "Notes" : "Notebooks";
return confirm(Icon.Trash, {
- title: `Delete these ${noun}`,
- subtitle: `Are you sure you want to delete these ${type}s?`,
+ title: `Delete these ${noun}?`,
message: (
<Text as="span">
These {type}s will be{" "}
@@ -90,10 +89,9 @@ export function showMultiDeleteConfirmation(type) {
export function showLogoutConfirmation() {
return confirm(Icon.Logout, {
- title: `Logout`,
- subtitle: `Are you sure you want to logout?`,
+ title: `Logout?`,
message:
- "Logging out will delete all local data and reset the app. Make sure you have synced all your data before logging out.",
+ "Logging out will delete all local data and reset the app. Make sure you have synced your data before logging out.",
yesText: `Yes`,
noText: "No",
});
diff --git a/apps/web/src/components/dialogs/loading-dialog.js b/apps/web/src/components/dialogs/loading-dialog.js
new file mode 100644
index 000000000..aceb52e94
--- /dev/null
+++ b/apps/web/src/components/dialogs/loading-dialog.js
@@ -0,0 +1,42 @@
+import React, { useEffect } from "react";
+import { Box, Text } from "rebass";
+import Dialog, { showDialog } from "./dialog";
+import * as Icon from "../icons";
+
+function LoadingDialog(props) {
+ useEffect(() => {
+ (async function () {
+ await props.action();
+ props.onDone();
+ })();
+ }, [props]);
+
+ return (
+ <Dialog
+ isOpen={true}
+ title={props.title}
+ description={props.subtitle}
+ onClose={() => {}}
+ >
+ <Box>
+ <Text as="span" variant="body">
+ {props.message}
+ </Text>
+ <Icon.Loading rotate sx={{ mt: 2 }} color="primary" />
+ </Box>
+ </Dialog>
+ );
+}
+
+export function showLoadingDialog(dialogData) {
+ const { title, message, subtitle, action } = dialogData;
+ return showDialog((perform) => (
+ <LoadingDialog
+ title={title}
+ subtitle={subtitle}
+ message={message}
+ action={action}
+ onDone={() => perform(true)}
+ />
+ ));
+}
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 9cb906c69..c44fa7c5c 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -17,6 +17,7 @@ import { showRecoveryKeyDialog } from "../components/dialogs/recoverykeydialog";
import { showBuyDialog } from "../components/dialogs/buy-dialog";
import Vault from "../common/vault";
import ScrollContainer from "../components/scroll-container";
+import { showLoadingDialog } from "../components/dialogs/loadingdialog";
function importBackup() {
return new Promise((resolve, reject) => {
@@ -270,7 +271,19 @@ function Settings(props) {
<Button
variant="list"
onClick={async () => {
- await db.backup.import(JSON.stringify(await importBackup()));
+ const backupData = JSON.stringify(await importBackup());
+ showLoadingDialog({
+ title: "Restoring backup",
+ subtitle: "We are restoring your backup. Please wait...",
+ action: async () => {
+ await db.backup.import(backupData);
+ },
+ message: (
+ <Text color="error">
+ Please do NOT close your browser or shut down your PC.
+ </Text>
+ ),
+ });
}}
>
<TextWithTip