show progress

This commit is contained in:
fyears
2022-01-08 14:45:36 +08:00
parent e7c24b55a3
commit c637038d95
2 changed files with 29 additions and 3 deletions
+20 -1
View File
@@ -64,6 +64,7 @@ export default class RemotelySavePlugin extends Plugin {
syncStatus: SyncStatusType;
oauth2Info: OAuth2Info;
currLogLevel: string;
currSyncMsg?: string;
async onload() {
log.info(`loading plugin ${this.manifest.id}`);
@@ -76,6 +77,8 @@ export default class RemotelySavePlugin extends Plugin {
revokeAuthSetting: undefined,
}; // init
this.currSyncMsg = "";
await this.loadSettings();
if (this.settings.currLogLevel !== undefined) {
@@ -282,6 +285,9 @@ export default class RemotelySavePlugin extends Plugin {
new Notice(
`Remotely Save already running in stage ${this.syncStatus}!`
);
if (this.currSyncMsg !== undefined && this.currSyncMsg !== "") {
new Notice(this.currSyncMsg);
}
return;
}
@@ -349,10 +355,13 @@ export default class RemotelySavePlugin extends Plugin {
this.db,
this.app.vault,
syncPlan,
this.settings.password
this.settings.password,
(i: number, totalCount: number, pathName: string, decision: string) =>
self.setCurrSyncMsg(i, totalCount, pathName, decision)
);
new Notice("7/7 Remotely Save finish!");
this.currSyncMsg = "";
this.syncStatus = "finish";
this.syncStatus = "idle";
} catch (error) {
@@ -479,4 +488,14 @@ export default class RemotelySavePlugin extends Plugin {
destroyDBs() {
/* destroyDBs(this.db); */
}
async setCurrSyncMsg(
i: number,
totalCount: number,
pathName: string,
decision: string
) {
const msg = `${i}/${totalCount}, ${decision}, ${pathName}`;
this.currSyncMsg = msg;
}
}