mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-05 17:07:43 +00:00
fix(popup): trigger CONNECT when popup opens with saved roomId
If user has a room configured but the background is not connected (e.g. service worker was killed, startup race, or stale state), the popup now sends CONNECT on open. Previously it only called GET_STATUS and showed 'disconnected' with 0 logs — the user had no way to know whether the extension was working.
This commit is contained in:
@@ -255,6 +255,13 @@ async function init() {
|
||||
updatePeerList(res.peers);
|
||||
lastKnownPeers = res.peers || [];
|
||||
if (res.lastActionState) updateLastActionUI(res.lastActionState, res.peers);
|
||||
|
||||
// If user has a room configured but background is not connected,
|
||||
// trigger connection now — the popup opening is explicit user intent.
|
||||
if (res.status === 'disconnected' && localData.roomId) {
|
||||
chrome.runtime.sendMessage({ type: 'CONNECT' }).catch(() => {});
|
||||
applyConnectionStatus('connecting');
|
||||
}
|
||||
|
||||
// Populate Tabs using the background's targetTabId
|
||||
await populateTabs(res.peers, res.targetTabId);
|
||||
|
||||
Reference in New Issue
Block a user