diff --git a/src/services/workspaces/index.ts b/src/services/workspaces/index.ts index 645a0d58..d2487a4a 100644 --- a/src/services/workspaces/index.ts +++ b/src/services/workspaces/index.ts @@ -169,11 +169,20 @@ export class Workspace implements IWorkspaceService { /** * Get sorted workspace list + * Async so proxy type is async */ public async getWorkspacesAsList(): Promise { return Object.values(this.workspaces).sort((a, b) => a.order - b.order); } + /** + * Get sorted workspace list + * Sync for internal use + */ + private getWorkspacesAsListSync(): IWorkspace[] { + return Object.values(this.workspaces).sort((a, b) => a.order - b.order); + } + public async get(id: string): Promise { return this.workspaces[id]; } @@ -216,7 +225,7 @@ export class Workspace implements IWorkspaceService { // we add mainWikiID in creation, we fix this value for old existed workspaces // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions if (workspaceToSanitize.isSubWiki && !workspaceToSanitize.mainWikiID) { - const mainWorkspace = (this.getWorkspacesAsList() as unknown as IWorkspace[]).find( + const mainWorkspace = (this.getWorkspacesAsListSync() ?? []).find( (workspaceToSearch) => workspaceToSanitize.mainWikiToLink === workspaceToSearch.wikiFolderLocation, ); if (mainWorkspace !== undefined) {