From 9f8b2cc9871dfdaa5c4df2fa78f9874c08858f91 Mon Sep 17 00:00:00 2001 From: jay Date: Thu, 14 May 2026 18:59:13 +0200 Subject: [PATCH] Revert "fix: faster WebSocket reconnect on iOS PWA" This reverts commit c21b6c441c03e9ac3a167cdad7c4ec753e18173a. --- extensions/remote-control/html.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/extensions/remote-control/html.ts b/extensions/remote-control/html.ts index 5f0987b..7c77d09 100644 --- a/extensions/remote-control/html.ts +++ b/extensions/remote-control/html.ts @@ -607,26 +607,17 @@ export function buildHTML(nonce: string): string { } } - var ws, timer, connectTimer; + var ws, timer; function connect() { - if (ws && (ws.readyState === 0 || ws.readyState === 1)) return; - clearTimeout(connectTimer); var wsProtocol = location.protocol === "https:" ? "wss:" : "ws:"; ws = new WebSocket(wsProtocol + "//" + location.host + "/ws"); - // If not connected within 4s, close and retry immediately - connectTimer = setTimeout(function () { - if (ws && ws.readyState !== 1) { ws.close(); } - }, 4000); - ws.onopen = function () { clearTimeout(timer); - clearTimeout(connectTimer); updateStatus(true); }; ws.onclose = function () { - clearTimeout(connectTimer); updateStatus(false); clearTimeout(timer); timer = setTimeout(connect, 2000); @@ -726,14 +717,6 @@ export function buildHTML(nonce: string): string { }); connect(); - - // Reconnect immediately when app comes back to foreground (e.g. iOS PWA resume) - document.addEventListener("visibilitychange", function () { - if (document.visibilityState === "visible") { - clearTimeout(timer); - if (!ws || ws.readyState === 2 || ws.readyState === 3) connect(); - } - }); })();