Minor clean

pull/483/head
Zef Hemel 2023-07-27 15:25:33 +02:00
parent a3ad239b09
commit 4ba11ac66c
2 changed files with 14 additions and 13 deletions

View File

@ -160,12 +160,15 @@ export class Client {
} }
this.initNavigator(); this.initNavigator();
await this.loadPlugs();
await this.reloadPlugs(); this.initSync();
this.loadCustomStyles().catch(console.error); this.loadCustomStyles().catch(console.error);
// Kick off background sync await this.dispatchAppEvent("editor:init");
}
private initSync() {
this.syncService.start(); this.syncService.start();
this.eventHook.addLocalListener("sync:success", async (operations) => { this.eventHook.addLocalListener("sync:success", async (operations) => {
@ -207,8 +210,6 @@ export class Client {
Math.round(status.filesProcessed / status.totalFiles * 100), Math.round(status.filesProcessed / status.totalFiles * 100),
); );
}); });
await this.dispatchAppEvent("editor:init");
} }
private initNavigator() { private initNavigator() {
@ -353,6 +354,10 @@ export class Client {
return this.ui.viewState.currentPage; return this.ui.viewState.currentPage;
} }
dispatchAppEvent(name: AppEvent, ...args: any[]): Promise<any[]> {
return this.eventHook.dispatchEvent(name, ...args);
}
save(immediate = false): Promise<void> { save(immediate = false): Promise<void> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (this.saveTimeout) { if (this.saveTimeout) {
@ -499,11 +504,7 @@ export class Client {
}); });
} }
dispatchAppEvent(name: AppEvent, ...args: any[]): Promise<any[]> { async loadPlugs() {
return this.eventHook.dispatchEvent(name, ...args);
}
async reloadPlugs() {
await this.system.reloadPlugsFromSpace(this.space); await this.system.reloadPlugsFromSpace(this.space);
this.rebuildEditorState(); this.rebuildEditorState();
await this.dispatchAppEvent("plugs:loaded"); await this.dispatchAppEvent("plugs:loaded");
@ -515,7 +516,7 @@ export class Client {
this.system.updateMarkdownParser(); this.system.updateMarkdownParser();
if (editorView && this.currentPage) { if (this.currentPage) {
// And update the editor if a page is loaded // And update the editor if a page is loaded
this.openPages.saveState(this.currentPage); 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); const cmd = this.ui.viewState.commands.get(name);
if (cmd) { if (cmd) {
await cmd.run(); await cmd.run();

View File

@ -41,7 +41,7 @@ export function systemSyscalls(
return allCommands; return allCommands;
}, },
"system.reloadPlugs": () => { "system.reloadPlugs": () => {
return editor.reloadPlugs(); return editor.loadPlugs();
}, },
"system.getEnv": () => { "system.getEnv": () => {
return system.env; return system.env;