Skip to content

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

fix: hide backup restore button for non-logged in users

thecodrr52a1a42024fb
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index 414e77d14..7f6d9f6fd 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -439,64 +439,65 @@ function Settings(props) {
tip="Create a backup file of all your data"
/>
</Button>
+ {isLoggedIn && (
+ <>
+ <Button
+ variant="list"
+ onClick={async () => {
+ await importBackup();
+ await refreshApp();
+ }}
+ >
+ <Tip
+ text="Restore backup"
+ tip="Restore data from a backup file"
+ />
+ </Button>
+ <Toggle
+ title="Encrypt backups"
+ onTip="All backup files will be encrypted"
+ offTip="Backup files will not be encrypted"
+ onToggled={toggleEncryptBackups}
+ premium={CHECK_IDS.backupEncrypt}
+ isToggled={encryptBackups}
+ />
- <Button
- variant="list"
- onClick={async () => {
- if (!isLoggedIn)
- throw new Error("You must be logged in to restore backups.");
- await importBackup();
- await refreshApp();
- }}
- >
- <Tip
- text="Restore backup"
- tip="Restore data from a backup file"
- />
- </Button>
- <Toggle
- title="Encrypt backups"
- onTip="All backup files will be encrypted"
- offTip="Backup files will not be encrypted"
- onToggled={toggleEncryptBackups}
- premium={CHECK_IDS.backupEncrypt}
- isToggled={encryptBackups}
- />
-
- <OptionsItem
- title={isDesktop() ? "Automatic backups" : "Backup reminders"}
- tip={
- isDesktop()
- ? "Automatically backup my data"
- : "Remind me to backup my data"
- }
- options={["Never", "Daily", "Weekly", "Monthly"]}
- premium="backups"
- selectedOption={backupReminderOffset}
- onSelectionChanged={(_option, index) =>
- setBackupReminderOffset(index)
- }
- />
- {isDesktop() && !!backupReminderOffset ? (
- <Button
- key={"backupLocation"}
- variant="list"
- onClick={async () => {
- const location = await window.native.selectDirectory({
- title: "Select where Notesnook should save backups",
- defaultPath:
- backupStorageLocation || PATHS.backupsDirectory,
- });
- if (!location) return;
- setBackupStorageLocation(location);
- }}
- >
- <Tip
- text={"Change backups storage location"}
- tip={backupStorageLocation}
+ <OptionsItem
+ title={isDesktop() ? "Automatic backups" : "Backup reminders"}
+ tip={
+ isDesktop()
+ ? "Automatically backup my data"
+ : "Remind me to backup my data"
+ }
+ options={["Never", "Daily", "Weekly", "Monthly"]}
+ premium="backups"
+ selectedOption={backupReminderOffset}
+ onSelectionChanged={(_option, index) =>
+ setBackupReminderOffset(index)
+ }
/>
- </Button>
- ) : null}
+ {isDesktop() && !!backupReminderOffset ? (
+ <Button
+ key={"backupLocation"}
+ variant="list"
+ onClick={async () => {
+ const location = await window.native.selectDirectory({
+ title: "Select where Notesnook should save backups",
+ defaultPath:
+ backupStorageLocation || PATHS.backupsDirectory,
+ });
+ if (!location) return;
+ setBackupStorageLocation(location);
+ }}
+ >
+ <Tip
+ text={"Change backups storage location"}
+ tip={backupStorageLocation}
+ />
+ </Button>
+ ) : null}
+ </>
+ )}
</>
)}