refactor: remove unneeded bridgeLoaded listener
This commit is contained in:
parent
210a9f12ce
commit
cae343cdcc
|
@ -6,7 +6,6 @@ import {
|
||||||
getAuthStatusKnown,
|
getAuthStatusKnown,
|
||||||
getAuthStatusResolve,
|
getAuthStatusResolve,
|
||||||
getBlockForBootloader,
|
getBlockForBootloader,
|
||||||
getBlockForBridge,
|
|
||||||
getKernelIframe,
|
getKernelIframe,
|
||||||
getOpenPorts,
|
getOpenPorts,
|
||||||
getQueries,
|
getQueries,
|
||||||
|
@ -21,13 +20,11 @@ export function handleKernelMessage(event: MessageEvent) {
|
||||||
let data = event.data.data;
|
let data = event.data.data;
|
||||||
|
|
||||||
if (event.data.method === "kernelBridgeVersion") {
|
if (event.data.method === "kernelBridgeVersion") {
|
||||||
getBlockForBridge().then(() => {
|
|
||||||
for (let [, port] of Object.entries(getOpenPorts())) {
|
for (let [, port] of Object.entries(getOpenPorts())) {
|
||||||
try {
|
try {
|
||||||
(port as any).postMessage(event.data);
|
(port as any).postMessage(event.data);
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,3 @@ function handleMessage(event: MessageEvent) {
|
||||||
// Everything else just gets ignored.
|
// Everything else just gets ignored.
|
||||||
}
|
}
|
||||||
window.addEventListener("message", handleMessage);
|
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 authStatus: KernelAuthStatus;
|
||||||
let authStatusKnown = false;
|
let authStatusKnown = false;
|
||||||
let authStatusResolve: DataFn;
|
let authStatusResolve: DataFn;
|
||||||
let bridgeLoadedResolve: DataFn;
|
|
||||||
let blockForBootloader = new Promise((resolve) => {
|
let blockForBootloader = new Promise((resolve) => {
|
||||||
authStatusResolve = resolve;
|
authStatusResolve = resolve;
|
||||||
});
|
});
|
||||||
let blockForBridge = new Promise((resolve) => {
|
|
||||||
bridgeLoadedResolve = resolve;
|
|
||||||
});
|
|
||||||
let kernelFrame: HTMLIFrameElement;
|
let kernelFrame: HTMLIFrameElement;
|
||||||
let blockForDnsSetup = defer();
|
let blockForDnsSetup = defer();
|
||||||
let booted = defer();
|
let booted = defer();
|
||||||
|
let loggedInDefer = defer();
|
||||||
|
|
||||||
export function getAuthStatusKnown() {
|
export function getAuthStatusKnown() {
|
||||||
return authStatusKnown;
|
return authStatusKnown;
|
||||||
|
@ -107,12 +104,6 @@ export function getAuthStatusResolve(): DataFn {
|
||||||
export function getBlockForBootloader(): Promise<unknown> {
|
export function getBlockForBootloader(): Promise<unknown> {
|
||||||
return blockForBootloader;
|
return blockForBootloader;
|
||||||
}
|
}
|
||||||
export function getBlockForBridge(): Promise<unknown> {
|
|
||||||
return blockForBridge;
|
|
||||||
}
|
|
||||||
export function getBridgeLoadedResolve(): DataFn {
|
|
||||||
return bridgeLoadedResolve;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getBooted(): Promise<unknown> {
|
export function getBooted(): Promise<unknown> {
|
||||||
return booted.promise;
|
return booted.promise;
|
||||||
|
@ -121,3 +112,10 @@ export function getBooted(): Promise<unknown> {
|
||||||
export function weAreBooted(): void {
|
export function weAreBooted(): void {
|
||||||
booted.resolve();
|
booted.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getLoggedInDefer() {
|
||||||
|
return loggedInDefer;
|
||||||
|
}
|
||||||
|
export function resetLoggedInDefer() {
|
||||||
|
loggedInDefer = defer();
|
||||||
|
}
|
||||||
|
|
Reference in New Issue