From 7f647758c2238be4443d91c08657d57555429fac Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 1 Apr 2022 15:03:12 +0200 Subject: [PATCH] Fix some nasty bug --- webapp/hooks/completer.ts | 4 ++-- webapp/navigator.ts | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/webapp/hooks/completer.ts b/webapp/hooks/completer.ts index 6119760c..ecf1d4d2 100644 --- a/webapp/hooks/completer.ts +++ b/webapp/hooks/completer.ts @@ -17,7 +17,7 @@ export class CompleterHook implements Hook { continue; } for (const [functionName, functionDef] of Object.entries( - plug.manifest.functions + plug.manifest.functions )) { if (functionDef.isCompleter) { completerPromises.push(plug.invoke(functionName, [])); @@ -29,7 +29,7 @@ export class CompleterHook implements Hook { if (result) { if (actualResult) { console.error( - "Got completion results from multiple sources, cannot deal with that" + "Got completion results from multiple sources, cannot deal with that" ); return null; } diff --git a/webapp/navigator.ts b/webapp/navigator.ts index c00fd606..9f85f53e 100644 --- a/webapp/navigator.ts +++ b/webapp/navigator.ts @@ -27,22 +27,19 @@ export class PathPageNavigator { subscribe( pageLoadCallback: (pageName: string, pos: number) => Promise ): void { - const cb = (event?: PopStateEvent) => { - const gotoPage = this.getCurrentPage(); - if (!gotoPage) { - return; + const cb = (event?: PopStateEvent) => { + const gotoPage = this.getCurrentPage(); + if (!gotoPage) { + return; + } + safeRun(async () => { + await pageLoadCallback(this.getCurrentPage(), event && event.state.pos); + if (this.navigationResolve) { + this.navigationResolve(); } - safeRun(async () => { - await pageLoadCallback( - this.getCurrentPage(), - event && event.state.pos - ); - if (this.navigationResolve) { - this.navigationResolve(); - } - }); - }; - window.addEventListener("popstate", cb); + }); + }; + window.addEventListener("popstate", cb); cb(); }