From cae343cdccfe7bc60ce7f5515b30bf10a9a3cd25 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 19 Jul 2023 05:06:08 -0400 Subject: [PATCH] refactor: remove unneeded bridgeLoaded listener --- src/main/background/kernel.ts | 13 +++++-------- src/main/bridge.ts | 3 --- src/vars.ts | 18 ++++++++---------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/main/background/kernel.ts b/src/main/background/kernel.ts index 868d8d4..07e0cee 100644 --- a/src/main/background/kernel.ts +++ b/src/main/background/kernel.ts @@ -6,7 +6,6 @@ import { getAuthStatusKnown, getAuthStatusResolve, getBlockForBootloader, - getBlockForBridge, getKernelIframe, getOpenPorts, getQueries, @@ -21,13 +20,11 @@ export function handleKernelMessage(event: MessageEvent) { let data = event.data.data; if (event.data.method === "kernelBridgeVersion") { - getBlockForBridge().then(() => { - for (let [, port] of Object.entries(getOpenPorts())) { - try { - (port as any).postMessage(event.data); - } catch {} - } - }); + for (let [, port] of Object.entries(getOpenPorts())) { + try { + (port as any).postMessage(event.data); + } catch {} + } return; } diff --git a/src/main/bridge.ts b/src/main/bridge.ts index 0623fe3..04440e3 100644 --- a/src/main/bridge.ts +++ b/src/main/bridge.ts @@ -130,6 +130,3 @@ function handleMessage(event: MessageEvent) { // Everything else just gets ignored. } window.addEventListener("message", handleMessage); -port.postMessage({ - method: "bridgeLoaded", -}); diff --git a/src/vars.ts b/src/vars.ts index 7ab5c2f..9d800f3 100644 --- a/src/vars.ts +++ b/src/vars.ts @@ -10,16 +10,13 @@ export let timer = 20000; let authStatus: KernelAuthStatus; let authStatusKnown = false; let authStatusResolve: DataFn; -let bridgeLoadedResolve: DataFn; let blockForBootloader = new Promise((resolve) => { authStatusResolve = resolve; }); -let blockForBridge = new Promise((resolve) => { - bridgeLoadedResolve = resolve; -}); let kernelFrame: HTMLIFrameElement; let blockForDnsSetup = defer(); let booted = defer(); +let loggedInDefer = defer(); export function getAuthStatusKnown() { return authStatusKnown; @@ -107,12 +104,6 @@ export function getAuthStatusResolve(): DataFn { export function getBlockForBootloader(): Promise { return blockForBootloader; } -export function getBlockForBridge(): Promise { - return blockForBridge; -} -export function getBridgeLoadedResolve(): DataFn { - return bridgeLoadedResolve; -} export function getBooted(): Promise { return booted.promise; @@ -121,3 +112,10 @@ export function getBooted(): Promise { export function weAreBooted(): void { booted.resolve(); } + +export function getLoggedInDefer() { + return loggedInDefer; +} +export function resetLoggedInDefer() { + loggedInDefer = defer(); +}