refactor: remove unneeded bridgeLoaded listener
This commit is contained in:
parent
210a9f12ce
commit
cae343cdcc
|
@ -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 {}
|
||||
}
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,3 @@ function handleMessage(event: MessageEvent) {
|
|||
// Everything else just gets ignored.
|
||||
}
|
||||
window.addEventListener("message", handleMessage);
|
||||
port.postMessage({
|
||||
method: "bridgeLoaded",
|
||||
});
|
||||
|
|
18
src/vars.ts
18
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<unknown> {
|
||||
return blockForBootloader;
|
||||
}
|
||||
export function getBlockForBridge(): Promise<unknown> {
|
||||
return blockForBridge;
|
||||
}
|
||||
export function getBridgeLoadedResolve(): DataFn {
|
||||
return bridgeLoadedResolve;
|
||||
}
|
||||
|
||||
export function getBooted(): Promise<unknown> {
|
||||
return booted.promise;
|
||||
|
@ -121,3 +112,10 @@ export function getBooted(): Promise<unknown> {
|
|||
export function weAreBooted(): void {
|
||||
booted.resolve();
|
||||
}
|
||||
|
||||
export function getLoggedInDefer() {
|
||||
return loggedInDefer;
|
||||
}
|
||||
export function resetLoggedInDefer() {
|
||||
loggedInDefer = defer();
|
||||
}
|
||||
|
|
Reference in New Issue