mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-30 04:19:27 +00:00
fix(popup): join timeout checks connection status instead of blind 15s timer
Lazy-connect introduces a new state where the user clicks 'Raum erstellen' and the WebSocket takes 1-2s to establish (previously always pre-connected). The old 15s blind timeout would re-enable the button while background was still connecting, causing silent no-op clicks. Now polls GET_STATUS and extends the window if still connecting.
This commit is contained in:
+17
-5
@@ -1195,11 +1195,23 @@ elements.joinBtn.addEventListener('click', async () => {
|
|||||||
|
|
||||||
if (joinBtnTimeout) clearTimeout(joinBtnTimeout);
|
if (joinBtnTimeout) clearTimeout(joinBtnTimeout);
|
||||||
joinBtnTimeout = setTimeout(() => {
|
joinBtnTimeout = setTimeout(() => {
|
||||||
elements.joinBtn.disabled = false;
|
chrome.runtime.sendMessage({ type: 'GET_STATUS' }, (res) => {
|
||||||
elements.joinBtn.textContent = getMessage('BTN_JOIN_ROOM');
|
if (res && res.status === 'connecting') {
|
||||||
joinBtnTimeout = null;
|
joinBtnTimeout = setTimeout(() => {
|
||||||
isProcessingConnection = false;
|
elements.joinBtn.disabled = false;
|
||||||
showError(getMessage('ERR_CONN_TIMEOUT'));
|
elements.joinBtn.textContent = getMessage('BTN_JOIN_ROOM');
|
||||||
|
joinBtnTimeout = null;
|
||||||
|
isProcessingConnection = false;
|
||||||
|
showError(getMessage('ERR_CONN_TIMEOUT'));
|
||||||
|
}, 15000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
elements.joinBtn.disabled = false;
|
||||||
|
elements.joinBtn.textContent = getMessage('BTN_JOIN_ROOM');
|
||||||
|
joinBtnTimeout = null;
|
||||||
|
isProcessingConnection = false;
|
||||||
|
if (res && res.status !== 'connected') showError(getMessage('ERR_CONN_TIMEOUT'));
|
||||||
|
});
|
||||||
}, 15000);
|
}, 15000);
|
||||||
|
|
||||||
const serverUrl = elements.serverUrl.value.trim();
|
const serverUrl = elements.serverUrl.value.trim();
|
||||||
|
|||||||
Reference in New Issue
Block a user