From 0473ea177f5c674277febb41bc82bbf57314d5cc Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sun, 28 May 2023 00:55:19 +0800 Subject: [PATCH] feat: sync all subwiki together, if main workspace set to sync fixes #397 --- src/services/wiki/index.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/services/wiki/index.ts b/src/services/wiki/index.ts index 271fa9e9..5d8b983b 100644 --- a/src/services/wiki/index.ts +++ b/src/services/wiki/index.ts @@ -566,10 +566,18 @@ export class Wiki implements IWikiService { const syncDebounceInterval = await this.preferenceService.get('syncDebounceInterval'); this.wikiSyncIntervals[id] = setInterval(async () => { await this.syncWikiIfNeeded(workspace); + // sync all subwiki together, if main workspace set to sync + await this.syncAllSubWikiIfNeeded(workspace); }, syncDebounceInterval); } } + private async syncAllSubWikiIfNeeded(workspace: IWorkspace) { + const workspaces = await this.workspaceService.getWorkspacesAsList(); + const subWikiWorkspaces = workspaces.filter((w) => w.mainWikiID === workspace.id); + await Promise.all(subWikiWorkspaces.map((w) => this.syncWikiIfNeeded(w))); + } + private stopIntervalSync(workspace: IWorkspace): void { const { id } = workspace; if (typeof this.wikiSyncIntervals[id] === 'number') {