Skip to content

Commit

Permalink
Minor clean
Browse files Browse the repository at this point in the history
  • Loading branch information
zefhemel committed Jul 27, 2023
1 parent a3ad239 commit 4ba11ac
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions web/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -207,8 +210,6 @@ export class Client {
Math.round(status.filesProcessed / status.totalFiles * 100),
);
});

await this.dispatchAppEvent("editor:init");
}

private initNavigator() {
Expand Down Expand Up @@ -353,6 +354,10 @@ export class Client {
return this.ui.viewState.currentPage;
}

dispatchAppEvent(name: AppEvent, ...args: any[]): Promise<any[]> {
return this.eventHook.dispatchEvent(name, ...args);
}

save(immediate = false): Promise<void> {
return new Promise((resolve, reject) => {
if (this.saveTimeout) {
Expand Down Expand Up @@ -499,11 +504,7 @@ export class Client {
});
}

dispatchAppEvent(name: AppEvent, ...args: any[]): Promise<any[]> {
return this.eventHook.dispatchEvent(name, ...args);
}

async reloadPlugs() {
async loadPlugs() {
await this.system.reloadPlugsFromSpace(this.space);
this.rebuildEditorState();
await this.dispatchAppEvent("plugs:loaded");
Expand All @@ -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);

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion web/syscalls/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export function systemSyscalls(
return allCommands;
},
"system.reloadPlugs": () => {
return editor.reloadPlugs();
return editor.loadPlugs();
},
"system.getEnv": () => {
return system.env;
Expand Down

0 comments on commit 4ba11ac

Please sign in to comment.