Skip to content

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

feat: show backup dialog instead of saving backup directly

thecodrr00d623d929f9
diff --git a/apps/web/src/common/dialogcontroller.js b/apps/web/src/common/dialogcontroller.js
index f184af9a0..7558cc885 100644
--- a/apps/web/src/common/dialogcontroller.js
+++ b/apps/web/src/common/dialogcontroller.js
@@ -107,6 +107,12 @@ export function showBuyDialog(plan, couponCode) {
));
}
+export function showBackupDialog() {
+ return showDialog((Dialogs, perform) => (
+ <Dialogs.BackupDialog onClose={() => perform(false)} />
+ ));
+}
+
export function confirm({
title,
subtitle,
diff --git a/apps/web/src/common/reminders.js b/apps/web/src/common/reminders.js
index 6198d6d99..77b6b4b75 100644
--- a/apps/web/src/common/reminders.js
+++ b/apps/web/src/common/reminders.js
@@ -4,7 +4,10 @@ import { db } from "./db";
import { store as appStore } from "../stores/app-store";
import * as Icon from "../components/icons";
import dayjs from "dayjs";
-import { showRecoveryKeyDialog } from "../common/dialog-controller";
+import {
+ showBackupDialog,
+ showRecoveryKeyDialog,
+} from "../common/dialog-controller";
import { hardNavigate, hashNavigate } from "../navigation";
import { isDesktop } from "../utils/platform";
import saveFile from "../commands/save-file";
@@ -35,7 +38,7 @@ export async function shouldAddRecoveryKeyBackupReminder() {
const recoveryKeyBackupDate = Config.get("recoveryKeyBackupDate", 0);
if (!recoveryKeyBackupDate) return true;
- return dayjs(recoveryKeyBackupDate).add(7, "d").isBefore(dayjs());
+ return dayjs(recoveryKeyBackupDate).add(30, "d").isBefore(dayjs());
}
export async function shouldAddLoginReminder() {
@@ -99,7 +102,7 @@ export async function resetReminders() {
saveFile(filePath, data);
showToast("success", `Backup saved at ${filePath}.`);
} else if (isUserPremium()) {
- await createBackup(true);
+ await showBackupDialog();
}
}
if (await shouldAddLoginReminder()) {
diff --git a/apps/web/src/components/dialogs/backupdialog.tsx b/apps/web/src/components/dialogs/backupdialog.tsx
new file mode 100644
index 000000000..dcabccde3
--- /dev/null
+++ b/apps/web/src/components/dialogs/backupdialog.tsx
@@ -0,0 +1,39 @@
+import { Text } from "rebass";
+import { createBackup } from "../../common";
+import Dialog from "./dialog";
+
+type BackupDialogProps = {
+ onClose: () => void;
+};
+function BackupDialog(props: BackupDialogProps) {
+ return (
+ <Dialog
+ isOpen={true}
+ alignment="center"
+ onClose={props.onClose}
+ title="Your backup is ready"
+ description="Download a backup of your notes to keep them safe."
+ positiveButton={{
+ text: "Save to disk",
+ onClick: async () => {
+ await createBackup(true);
+ props.onClose();
+ },
+ }}
+ negativeButton={{
+ text: "Remind me later",
+ onClick: async () => {
+ await createBackup(false);
+ props.onClose();
+ },
+ }}
+ >
+ <Text variant={"body"}>
+ In case forget your password or something unfortunate happens, you can
+ restore a backup to recover lost data.{" "}
+ </Text>
+ </Dialog>
+ );
+}
+
+export default BackupDialog;
diff --git a/apps/web/src/components/dialogs/index.js b/apps/web/src/components/dialogs/index.js
index 23cadea91..fdd593256 100644
--- a/apps/web/src/components/dialogs/index.js
+++ b/apps/web/src/components/dialogs/index.js
@@ -16,6 +16,7 @@ import AnnouncementDialog from "./announcementdialog";
import IssueDialog from "./issuedialog";
import OnboardingDialog from "./onboarding-dialog";
import AttachmentsDialog from "./attachmentsdialog";
+import BackupDialog from "./backupdialog";
const Dialogs = {
AddNotebookDialog,
@@ -36,5 +37,6 @@ const Dialogs = {
ImportDialog,
OnboardingDialog,
AttachmentsDialog,
+ BackupDialog,
};
export default Dialogs;