mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 04:15:48 -06:00
fix(ui): observe the active service worker after asset refresh (#119622)
This commit is contained in:
committed by
GitHub
parent
13523321b3
commit
6c53dbe2b0
@@ -115,27 +115,13 @@ async function fetchControlledAsset(
|
||||
assetPath: string,
|
||||
): Promise<{ controllerState: string | null; sha256: string }> {
|
||||
return page.evaluate(async (relativePath) => {
|
||||
const controller = navigator.serviceWorker.controller;
|
||||
if (controller && controller.state !== "activated") {
|
||||
await new Promise<void>((resolve) => {
|
||||
controller.addEventListener(
|
||||
"statechange",
|
||||
() => {
|
||||
if (controller.state === "activated") {
|
||||
resolve();
|
||||
}
|
||||
},
|
||||
{ once: true },
|
||||
);
|
||||
});
|
||||
}
|
||||
const response = await fetch(new URL(relativePath, window.location.href));
|
||||
if (!response.ok) {
|
||||
throw new Error(`Build asset request failed with HTTP ${response.status}`);
|
||||
}
|
||||
const digest = await crypto.subtle.digest("SHA-256", await response.arrayBuffer());
|
||||
return {
|
||||
controllerState: controller?.state ?? null,
|
||||
controllerState: navigator.serviceWorker.controller?.state ?? null,
|
||||
sha256: [...new Uint8Array(digest)]
|
||||
.map((byte) => byte.toString(16).padStart(2, "0"))
|
||||
.join(""),
|
||||
|
||||
Reference in New Issue
Block a user