fix status bar
This commit is contained in:
parent
5c1a887b07
commit
faa9df1306
@ -48,8 +48,8 @@
|
||||
"statusbar_sync_source_manual": "手动:",
|
||||
"statusbar_sync_source_dry": "空跑:",
|
||||
"statusbar_sync_source_auto": "自动:",
|
||||
"statusbar_sync_source_auto_once_init": "启动时自动:",
|
||||
"statusbar_sync_source_auto_sync_on_save": "保存时自动:",
|
||||
"statusbar_sync_source_auto_once_init": "启动时同步:",
|
||||
"statusbar_sync_source_auto_sync_on_save": "保存时同步:",
|
||||
"statusbar_sync_status_prefix_success": "同步成功:",
|
||||
"statusbar_sync_status_prefix_failed": "同步失败:",
|
||||
"statusbar_time_years": "{{time}} 年前",
|
||||
@ -58,7 +58,7 @@
|
||||
"statusbar_time_days": "{{time}} 天前",
|
||||
"statusbar_time_hours": "{{time}} 小时前",
|
||||
"statusbar_time_minutes": "{{time}} 分钟前",
|
||||
"statusbar_time_lessminute": "一分钟之内",
|
||||
"statusbar_time_lessminute": "1 分钟之内",
|
||||
"statusbar_time_now": "刚刚",
|
||||
"statusbar_syncing": "正在同步",
|
||||
"statusbar_lastsync_label": "日期:{{date}}",
|
||||
|
||||
@ -47,8 +47,8 @@
|
||||
"statusbar_sync_source_manual": "手動:",
|
||||
"statusbar_sync_source_dry": "空跑:",
|
||||
"statusbar_sync_source_auto": "自動:",
|
||||
"statusbar_sync_source_auto_once_init": "啟動時自動:",
|
||||
"statusbar_sync_source_auto_sync_on_save": "儲存時自動:",
|
||||
"statusbar_sync_source_auto_once_init": "啟動時同步:",
|
||||
"statusbar_sync_source_auto_sync_on_save": "儲存時同步:",
|
||||
"statusbar_sync_status_prefix_success": "同步成功:",
|
||||
"statusbar_sync_status_prefix_failed": "同步失敗:",
|
||||
"statusbar_time_years": "{{time}} 年前",
|
||||
@ -57,7 +57,7 @@
|
||||
"statusbar_time_days": "{{time}} 天前",
|
||||
"statusbar_time_hours": "{{time}} 小時前",
|
||||
"statusbar_time_minutes": "{{time}} 分鐘前",
|
||||
"statusbar_time_lessminute": "一分鐘之內",
|
||||
"statusbar_time_lessminute": "1 分鐘之內",
|
||||
"statusbar_time_now": "剛剛",
|
||||
"statusbar_syncing": "正在同步",
|
||||
"statusbar_lastsync_label": "日期:{{date}}",
|
||||
|
||||
25
src/main.ts
25
src/main.ts
@ -420,15 +420,15 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
) => {
|
||||
if (step === 1) {
|
||||
// change status to "syncing..." on statusbar
|
||||
this.updateLastSyncMsg(s, -1, -1);
|
||||
this.updateLastSyncMsg(s, "syncing", -1, -1);
|
||||
} else if (step === 8 && everythingOk) {
|
||||
const ts = Date.now();
|
||||
await upsertLastSuccessSyncTimeByVault(this.db, this.vaultRandomID, ts);
|
||||
this.updateLastSyncMsg(s, ts, null);
|
||||
this.updateLastSyncMsg(s, "not_syncing", ts, null); // hack: 'not_syncing'
|
||||
} else if (!everythingOk) {
|
||||
const ts = Date.now();
|
||||
await upsertLastFailedSyncTimeByVault(this.db, this.vaultRandomID, ts);
|
||||
this.updateLastSyncMsg(s, null, ts); // magic number
|
||||
this.updateLastSyncMsg(s, "not_syncing", null, ts);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1088,17 +1088,21 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
this.statusBarElement = statusBarItem.createEl("span");
|
||||
this.statusBarElement.setAttribute("data-tooltip-position", "top");
|
||||
|
||||
this.updateLastSyncMsg(
|
||||
undefined,
|
||||
await getLastSuccessSyncTimeByVault(this.db, this.vaultRandomID),
|
||||
await getLastFailedSyncTimeByVault(this.db, this.vaultRandomID)
|
||||
);
|
||||
if (!this.isSyncing) {
|
||||
this.updateLastSyncMsg(
|
||||
undefined,
|
||||
"not_syncing",
|
||||
await getLastSuccessSyncTimeByVault(this.db, this.vaultRandomID),
|
||||
await getLastFailedSyncTimeByVault(this.db, this.vaultRandomID)
|
||||
);
|
||||
}
|
||||
// update statusbar text every 30 seconds
|
||||
this.registerInterval(
|
||||
window.setInterval(async () => {
|
||||
if (!this.isSyncing) {
|
||||
this.updateLastSyncMsg(
|
||||
undefined,
|
||||
"not_syncing",
|
||||
await getLastSuccessSyncTimeByVault(this.db, this.vaultRandomID),
|
||||
await getLastFailedSyncTimeByVault(this.db, this.vaultRandomID)
|
||||
);
|
||||
@ -1798,6 +1802,7 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
|
||||
updateLastSyncMsg(
|
||||
s: SyncTriggerSourceType | undefined,
|
||||
syncStatus: "not_syncing" | "syncing",
|
||||
lastSuccessSyncMillis: number | null | undefined,
|
||||
lastFailedSyncMillis: number | null | undefined
|
||||
) {
|
||||
@ -1820,9 +1825,7 @@ export default class RemotelySavePlugin extends Plugin {
|
||||
const isSuccess =
|
||||
(lastSuccessSyncMillis ?? -999) >= (lastFailedSyncMillis ?? -999);
|
||||
|
||||
if (this.isSyncing) {
|
||||
// magic number
|
||||
// otherwise how can we know we are syncing??
|
||||
if (syncStatus === "syncing") {
|
||||
lastSyncMsg =
|
||||
getStatusBarShortMsgFromSyncSource(t, s!) + t("statusbar_syncing");
|
||||
} else if (inputTs > 0) {
|
||||
|
||||
@ -2166,7 +2166,7 @@ export class RemotelySaveSettingTab extends PluginSettingTab {
|
||||
this.plugin.vaultRandomID,
|
||||
-1
|
||||
);
|
||||
this.plugin.updateLastSyncMsg(undefined, null, null);
|
||||
this.plugin.updateLastSyncMsg(undefined, "not_syncing", null, null);
|
||||
new Notice(t("settings_resetstatusbar_notice"));
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user