feat: sync all subwiki together, if main workspace set to sync

fixes #397
This commit is contained in:
lin onetwo 2023-05-28 00:55:19 +08:00
parent 731d756928
commit 0473ea177f

View file

@ -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') {