From 17de78240f72f368f9f95395cfa44d10f3f437d7 Mon Sep 17 00:00:00 2001 From: Vijayasantham <70528700+vijayasantham12@users.noreply.github.com> Date: Mon, 12 Feb 2024 14:43:43 +0530 Subject: [PATCH] Feat: Add #481 (#492) --- src/langs/en.json | 16 +++++++++------- src/main.ts | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/langs/en.json b/src/langs/en.json index d28c77d..4e36c3e 100644 --- a/src/langs/en.json +++ b/src/langs/en.json @@ -40,14 +40,16 @@ "command_exportsyncplans_json": "export sync plans in json format", "command_exportlogsindb": "export logs saved in db", - "statusbar_time_years": "{{time}} years", - "statusbar_time_months": "{{time}} months", - "statusbar_time_weeks": "{{time}} weeks", - "statusbar_time_days": "{{time}} days", - "statusbar_time_hours": "{{time}} hours", - "statusbar_time_minutes": "{{time}} minutes", - "statusbar_time_lessminute": "less than a minute", + "statusbar_time_years": "Synced {{time}} years ago", + "statusbar_time_months": "Synced {{time}} months ago", + "statusbar_time_weeks": "Synced {{time}} weeks ago", + "statusbar_time_days": "Synced {{time}} days ago", + "statusbar_time_hours": "Synced {{time}} hours ago", + "statusbar_time_minutes": "Synced {{time}} minutes ago", + "statusbar_time_lessminute": "Synced less than a minute ago", "statusbar_lastsync": "Synced {{time}} ago", + "statusbar_syncing": "Syncing...", + "statusbar_now": "Synced just now", "statusbar_lastsync_label": "Last successful Sync on {{date}}", "statusbar_lastsync_never": "Never Synced", "statusbar_lastsync_never_label": "Never Synced before", diff --git a/src/main.ts b/src/main.ts index ddc378d..ea7a96a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -203,6 +203,10 @@ export default class RemotelySavePlugin extends Plugin { } } + // change status to "syncing..." on statusbar + if (this.statusBarElement !== undefined) { + this.updateLastSuccessSyncMsg(-1); + } //log.info(`huh ${this.settings.password}`) if (this.settings.currLogLevel === "info") { getNotice( @@ -332,6 +336,7 @@ export default class RemotelySavePlugin extends Plugin { getNotice(t("syncrun_step7")); } this.syncStatus = "syncing"; + await doActualSync( client, this.db, @@ -1156,6 +1161,10 @@ export default class RemotelySavePlugin extends Plugin { let lastSyncMsg = t("statusbar_lastsync_never"); let lastSyncLabelMsg = t("statusbar_lastsync_never_label"); + if (lastSuccessSyncMillis !== undefined && lastSuccessSyncMillis === -1) { + lastSyncMsg = t("statusbar_syncing"); + } + if (lastSuccessSyncMillis !== undefined && lastSuccessSyncMillis > 0) { const deltaTime = Date.now() - lastSuccessSyncMillis; @@ -1166,6 +1175,8 @@ export default class RemotelySavePlugin extends Plugin { const days = Math.floor(deltaTime / 86400000); const hours = Math.floor(deltaTime / 3600000); const minutes = Math.floor(deltaTime / 60000); + const seconds = Math.floor(deltaTime / 1000); + let timeText = ""; if (years > 0) { @@ -1180,8 +1191,10 @@ export default class RemotelySavePlugin extends Plugin { timeText = t("statusbar_time_hours", { time: hours }); } else if (minutes > 0) { timeText = t("statusbar_time_minutes", { time: minutes }); - } else { + } else if (seconds > 30) { timeText = t("statusbar_time_lessminute"); + } else { + timeText = t("statusbar_now"); } let dateText = new Date(lastSuccessSyncMillis).toLocaleTimeString( @@ -1194,7 +1207,7 @@ export default class RemotelySavePlugin extends Plugin { } ); - lastSyncMsg = t("statusbar_lastsync", { time: timeText }); + lastSyncMsg = timeText; lastSyncLabelMsg = t("statusbar_lastsync_label", { date: dateText }); }