Skip to content

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

mobile: show last backup and next backup timestamps in Settings > Backups

kashaf-ansari-dev5ad4f9b341df
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 6c7c9d38b..7b04ed38f 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -1417,7 +1417,15 @@ export function getSettingsGroups(): SettingSection[] {
{
id: "backup-now",
name: strings.backupNow(),
- description: strings.backupNowDesc(),
+ property: "lastBackupDate",
+ description: () => {
+ const last = SettingsService.get().lastBackupDate;
+ return last
+ ? `${strings.backupNowDesc()}\n${strings.lastBackupOn(
+ dayjs(last).format("MMM D, YYYY [at] h:mm A")
+ )}`
+ : strings.backupNowDesc();
+ },
modifer: async () => {
const user = useUserStore.getState().user;
if (!user || SettingsService.getProperty("encryptedBackup")) {
@@ -1431,7 +1439,15 @@ export function getSettingsGroups(): SettingSection[] {
{
id: "backup-now-with-attachments",
name: strings.backupNowWithAttachments(),
- description: strings.backupNowWithAttachmentsDesc(),
+ property: "lastFullBackupDate",
+ description: () => {
+ const last = SettingsService.get().lastFullBackupDate;
+ return last
+ ? `${strings.backupNowWithAttachmentsDesc()}\n${strings.lastBackupOn(
+ dayjs(last).format("MMM D, YYYY [at] h:mm A")
+ )}`
+ : strings.backupNowWithAttachmentsDesc();
+ },
hidden: () => !useUserStore.getState().user,
modifer: async () => {
const user = useUserStore.getState().user;
@@ -1449,7 +1465,22 @@ export function getSettingsGroups(): SettingSection[] {
id: "auto-backups",
type: "component",
name: strings.automaticBackups(),
- description: strings.automaticBackupsDesc(),
+ useHook: () =>
+ useSettingStore((state) => [
+ state.settings.reminder,
+ state.settings.lastBackupDate
+ ]),
+ description: () => {
+ const next = BackupService.getNextBackupTime(
+ SettingsService.get().reminder,
+ "lastBackupDate"
+ );
+ return next
+ ? `${strings.automaticBackupsDesc()}\n${strings.nextBackupOn(
+ dayjs(next).format("MMM D, YYYY [at] h:mm A")
+ )}`
+ : strings.automaticBackupsDesc();
+ },
component: "autobackups"
},
{
@@ -1457,9 +1488,25 @@ export function getSettingsGroups(): SettingSection[] {
type: "component",
hidden: () => !useUserStore.getState().user,
name: strings.automaticBackupsWithAttachments(),
- description: [
+ useHook: () =>
+ useSettingStore((state) => [
+ state.settings.fullBackupReminder,
+ state.settings.lastFullBackupDate
+ ]),
+ description: () => {
+ const next = BackupService.getNextBackupTime(
+ SettingsService.get().fullBackupReminder,
+ "lastFullBackupDate"
+ );
+ const base = [
...strings.automaticBackupsWithAttachmentsDesc()
- ].join("\n"),
+ ].join("\n");
+ return next
+ ? `${base}\n${strings.nextBackupOn(
+ dayjs(next).format("MMM D, YYYY [at] h:mm A")
+ )}`
+ : base;
+ },
component: "autobackupsattachments"
},
{
diff --git a/apps/mobile/app/services/backup.ts b/apps/mobile/app/services/backup.ts
index f455c4fd2..d2221adf9 100644
--- a/apps/mobile/app/services/backup.ts
+++ b/apps/mobile/app/services/backup.ts
@@ -160,6 +160,21 @@ async function updateNextBackupTime(type: "full" | "partial") {
[type === "full" ? "lastFullBackupDate" : "lastBackupDate"]: Date.now()
});
}
+
+function getNextBackupTime(
+ type: "daily" | "off" | "useroff" | "weekly" | "monthly" | "never",
+ lastBackupDateType: "lastBackupDate" | "lastFullBackupDate" = "lastBackupDate"
+): number | undefined {
+ if (type === "off" || type === "useroff" || type === "never" || !type) return;
+ const lastBackupDate = SettingsService.getProperty(lastBackupDateType) as
+ | number
+ | undefined;
+ if (!lastBackupDate) return;
+ const interval =
+ type === "daily" ? MS_DAY : type === "weekly" ? MS_WEEK : MONTH;
+ return lastBackupDate + interval;
+}
+
let backupRunning = false;
/**
* @param {boolean=} progress
@@ -415,7 +430,8 @@ const BackupService = {
run,
checkAndRun,
getDirectoryAndroid,
- checkBackupDirExists
+ checkBackupDirExists,
+ getNextBackupTime
};
export default BackupService;
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index ea6068b6f..1a02d2bf0 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -4509,6 +4509,10 @@ msgstr "Languages"
msgid "Last"
msgstr "Last"
+#: src/strings.ts:3278
+msgid "Last backup: {date}"
+msgstr "Last backup: {date}"
+
#: src/strings.ts:2029
msgid "Last edited at"
msgstr "Last edited at"
@@ -5181,6 +5185,10 @@ msgstr "Newly created notes will be uncategorized"
msgid "Next"
msgstr "Next"
+#: src/strings.ts:3279
+msgid "Next backup: {date}"
+msgstr "Next backup: {date}"
+
#: src/strings.ts:2174
msgid "Next match"
msgstr "Next match"
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index f3a89f5a9..754886215 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -4509,6 +4509,10 @@ msgstr "Languages"
msgid "Last"
msgstr "Last"
+#: src/strings.ts:3278
+msgid "Last backup: {date}"
+msgstr ""
+
#: src/strings.ts:2029
msgid "Last edited at"
msgstr "Last edited at"
@@ -5181,6 +5185,10 @@ msgstr "Newly created notes will be uncategorized"
msgid "Next"
msgstr "Next"
+#: src/strings.ts:3279
+msgid "Next backup: {date}"
+msgstr ""
+
#: src/strings.ts:2174
msgid "Next match"
msgstr "Next match"
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 677566870..6d7eda308 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -3274,5 +3274,7 @@ Continue without attachments?`,
waitForPreviousDownloadToFinish: () =>
t`Please wait for the previous download to finish or cancel it.`,
checkingAttachmentsProgress: (current: number, total: number) =>
- t`Checking attachments (${current}/${total})`
+ t`Checking attachments (${current}/${total})`,
+ lastBackupOn: (date: string) => t`Last backup: ${date}`,
+ nextBackupOn: (date: string) => t`Next backup: ${date}`
};