minor change to synconsave

This commit is contained in:
fyears 2024-03-31 19:07:47 +08:00
parent 98107ba4ea
commit 4be67ce491
5 changed files with 19 additions and 14 deletions

View File

@ -272,9 +272,9 @@ export const DEFAULT_LOG_HISTORY_FILE_PREFIX = "log_hist_exported_on_";
export type SyncTriggerSourceType = export type SyncTriggerSourceType =
| "manual" | "manual"
| "auto"
| "dry" | "dry"
| "autoOnceInit" | "auto"
| "auto_once_init"
| "auto_sync_on_save"; | "auto_sync_on_save";
export const REMOTELY_SAVE_VERSION_2022 = "0.3.25"; export const REMOTELY_SAVE_VERSION_2022 = "0.3.25";

View File

@ -5,7 +5,7 @@
"goback": "Go Back", "goback": "Go Back",
"submit": "Submit", "submit": "Submit",
"sometext": "Here are some texts.", "sometext": "Here are some texts.",
"syncrun_alreadyrunning": "{{pluginName}} already running in stage {{syncStatus}}!", "syncrun_alreadyrunning": "New command {{newTriggerSource}} stops because {{pluginName}} is already running in stage {{syncStatus}}!",
"syncrun_syncingribbon": "{{pluginName}}: syncing from {{triggerSource}}", "syncrun_syncingribbon": "{{pluginName}}: syncing from {{triggerSource}}",
"syncrun_step0": "0/8 Remotely Save is running in dry mode, thus not actual file changes would happen.", "syncrun_step0": "0/8 Remotely Save is running in dry mode, thus not actual file changes would happen.",
"syncrun_step1": "1/8 Remotely Save is preparing ({{serviceType}})", "syncrun_step1": "1/8 Remotely Save is preparing ({{serviceType}})",

View File

@ -5,7 +5,7 @@
"goback": "返回", "goback": "返回",
"submit": "提交", "submit": "提交",
"sometext": "这里有一段文字。", "sometext": "这里有一段文字。",
"syncrun_alreadyrunning": "{{pluginName}} 正处于此阶段:{{syncStatus}}!", "syncrun_alreadyrunning": "{{pluginName}} 正处于此阶段:{{syncStatus}}!中断触发 {{newTriggerSource}}。",
"syncrun_syncingribbon": "{{pluginName}}:正在由 {{triggerSource}} 触发运行", "syncrun_syncingribbon": "{{pluginName}}:正在由 {{triggerSource}} 触发运行",
"syncrun_step0": "0/8 Remotely Save 在空跑dry run模式不会发生实际的文件交换。", "syncrun_step0": "0/8 Remotely Save 在空跑dry run模式不会发生实际的文件交换。",
"syncrun_step1": "1/8 Remotely Save 准备同步({{serviceType}}", "syncrun_step1": "1/8 Remotely Save 准备同步({{serviceType}}",

View File

@ -5,7 +5,7 @@
"goback": "返回", "goback": "返回",
"submit": "提交", "submit": "提交",
"sometext": "這裡有一段文字。", "sometext": "這裡有一段文字。",
"syncrun_alreadyrunning": "{{pluginName}} 正處於此階段:{{syncStatus}}!", "syncrun_alreadyrunning": "{{pluginName}} 正處於此階段:{{syncStatus}}! 中斷觸發 {{newTriggerSource}}。",
"syncrun_syncingribbon": "{{pluginName}}:正在由 {{triggerSource}} 觸發執行", "syncrun_syncingribbon": "{{pluginName}}:正在由 {{triggerSource}} 觸發執行",
"syncrun_step0": "0/8 Remotely Save 在空跑dry run模式不會發生實際的檔案交換。", "syncrun_step0": "0/8 Remotely Save 在空跑dry run模式不會發生實際的檔案交換。",
"syncrun_step1": "1/8 Remotely Save 準備同步({{serviceType}}", "syncrun_step1": "1/8 Remotely Save 準備同步({{serviceType}}",

View File

@ -167,15 +167,17 @@ export default class RemotelySavePlugin extends Plugin {
} }
}; };
if (this.syncStatus !== "idle") { if (this.syncStatus !== "idle") {
// here the notice is shown regardless of triggerSource // really, users don't want to see this in auto mode
new Notice( // so we use getNotice to avoid unnecessary show up
getNotice(
t("syncrun_alreadyrunning", { t("syncrun_alreadyrunning", {
pluginName: this.manifest.name, pluginName: this.manifest.name,
syncStatus: this.syncStatus, syncStatus: this.syncStatus,
newTriggerSource: triggerSource,
}) })
); );
if (this.currSyncMsg !== undefined && this.currSyncMsg !== "") { if (this.currSyncMsg !== undefined && this.currSyncMsg !== "") {
new Notice(this.currSyncMsg); getNotice(this.currSyncMsg);
} }
return; return;
} }
@ -378,7 +380,8 @@ export default class RemotelySavePlugin extends Plugin {
realCounter, realCounter,
realTotalCount, realTotalCount,
pathName, pathName,
decision decision,
triggerSource
), ),
this.db this.db
); );
@ -1105,7 +1108,7 @@ export default class RemotelySavePlugin extends Plugin {
) { ) {
this.app.workspace.onLayoutReady(() => { this.app.workspace.onLayoutReady(() => {
window.setTimeout(() => { window.setTimeout(() => {
this.syncRun("autoOnceInit"); this.syncRun("auto_once_init");
}, this.settings.initRunAfterMilliseconds); }, this.settings.initRunAfterMilliseconds);
}); });
} }
@ -1139,7 +1142,7 @@ export default class RemotelySavePlugin extends Plugin {
// if it has modified after lastSuccessSync // if it has modified after lastSuccessSync
// then schedule a run for syncOnSaveAfterMilliseconds after it was modified // then schedule a run for syncOnSaveAfterMilliseconds after it was modified
const lastModified = currentFile.stat.mtime; const lastModified = currentFile.stat.mtime;
const lastSuccessSyncMillis = await getLastSuccessSyncByVault( const lastSuccessSyncMillis = await getLastSuccessSyncTimeByVault(
this.db, this.db,
this.vaultRandomID this.vaultRandomID
); );
@ -1174,7 +1177,8 @@ export default class RemotelySavePlugin extends Plugin {
// listen to current file save changes // listen to current file save changes
this.registerEvent( this.registerEvent(
this.app.vault.on("modify", () => { this.app.vault.on("modify", (x) => {
// console.debug(`event=modify! file=${x}`);
checkCurrFileModified("FILE_CHANGES"); checkCurrFileModified("FILE_CHANGES");
}) })
); );
@ -1197,9 +1201,10 @@ export default class RemotelySavePlugin extends Plugin {
i: number, i: number,
totalCount: number, totalCount: number,
pathName: string, pathName: string,
decision: string decision: string,
triggerSource: SyncTriggerSourceType
) { ) {
const msg = `syncing progress=${i}/${totalCount},decision=${decision},path=${pathName}`; const msg = `syncing progress=${i}/${totalCount},decision=${decision},path=${pathName},source=${triggerSource}`;
this.currSyncMsg = msg; this.currSyncMsg = msg;
} }