embeds: add automatic reload if serivceWorker is available but controller is not to catch any race condition where serviceWorker has not yet been activated
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "replaywebpage",
|
"name": "replaywebpage",
|
||||||
"productName": "ReplayWeb.page",
|
"productName": "ReplayWeb.page",
|
||||||
"version": "1.0.2-dev.0",
|
"version": "1.0.2",
|
||||||
"description": "Serverless Web Archive Replay",
|
"description": "Serverless Web Archive Replay",
|
||||||
"repository": "https://github.com/webrecorder/replayweb.page",
|
"repository": "https://github.com/webrecorder/replayweb.page",
|
||||||
"homepage": "https://replayweb.page/",
|
"homepage": "https://replayweb.page/",
|
||||||
|
|||||||
+12
-3
@@ -183,13 +183,22 @@ Please try a different browser.\n
|
|||||||
if (this.injected) {
|
if (this.injected) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.target.contentWindow.customElements.get("replay-app-main")) {
|
const win = event.target.contentWindow;
|
||||||
|
const doc = event.target.contentDocument;
|
||||||
|
|
||||||
|
if (win.navigator.serviceWorker && !win.navigator.serviceWorker.controller) {
|
||||||
|
setTimeout(() => window.location.reload(), 100);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const script = event.target.contentDocument.createElement("script");
|
|
||||||
|
if (win.customElements.get("replay-app-main")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const script = doc.createElement("script");
|
||||||
//const script = event.target.contentDocument.querySelector("script");
|
//const script = event.target.contentDocument.querySelector("script");
|
||||||
script.src = scriptSrc;
|
script.src = scriptSrc;
|
||||||
event.target.contentDocument.head.appendChild(script);
|
doc.head.appendChild(script);
|
||||||
this.injected = true;
|
this.injected = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user