From 4ba11ac66c392839bd6672bf70912ab34ac1ad9c Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 27 Jul 2023 15:25:33 +0200 Subject: [PATCH] Minor clean --- web/client.ts | 25 +++++++++++++------------ web/syscalls/system.ts | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/web/client.ts b/web/client.ts index 1bc25baf..e8e4c788 100644 --- a/web/client.ts +++ b/web/client.ts @@ -160,12 +160,15 @@ export class Client { } this.initNavigator(); - - await this.reloadPlugs(); + await this.loadPlugs(); + this.initSync(); this.loadCustomStyles().catch(console.error); - // Kick off background sync + await this.dispatchAppEvent("editor:init"); + } + + private initSync() { this.syncService.start(); this.eventHook.addLocalListener("sync:success", async (operations) => { @@ -207,8 +210,6 @@ export class Client { Math.round(status.filesProcessed / status.totalFiles * 100), ); }); - - await this.dispatchAppEvent("editor:init"); } private initNavigator() { @@ -353,6 +354,10 @@ export class Client { return this.ui.viewState.currentPage; } + dispatchAppEvent(name: AppEvent, ...args: any[]): Promise { + return this.eventHook.dispatchEvent(name, ...args); + } + save(immediate = false): Promise { return new Promise((resolve, reject) => { if (this.saveTimeout) { @@ -499,11 +504,7 @@ export class Client { }); } - dispatchAppEvent(name: AppEvent, ...args: any[]): Promise { - return this.eventHook.dispatchEvent(name, ...args); - } - - async reloadPlugs() { + async loadPlugs() { await this.system.reloadPlugsFromSpace(this.space); this.rebuildEditorState(); await this.dispatchAppEvent("plugs:loaded"); @@ -515,7 +516,7 @@ export class Client { this.system.updateMarkdownParser(); - if (editorView && this.currentPage) { + if (this.currentPage) { // And update the editor if a page is loaded this.openPages.saveState(this.currentPage); @@ -731,7 +732,7 @@ export class Client { } } - async runCommandByName(name: string, ...args: any[]) { + async runCommandByName(name: string) { const cmd = this.ui.viewState.commands.get(name); if (cmd) { await cmd.run(); diff --git a/web/syscalls/system.ts b/web/syscalls/system.ts index d372f45a..3f3da885 100644 --- a/web/syscalls/system.ts +++ b/web/syscalls/system.ts @@ -41,7 +41,7 @@ export function systemSyscalls( return allCommands; }, "system.reloadPlugs": () => { - return editor.reloadPlugs(); + return editor.loadPlugs(); }, "system.getEnv": () => { return system.env;