mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-31 04:58:09 +00:00
fix: resolve metadata desync in heartbeats and restore remote control icons
This commit is contained in:
+16
-4
@@ -465,7 +465,7 @@ function handleServerEvent(event, data) {
|
|||||||
case EVENTS.FORCE_SYNC_PREPARE:
|
case EVENTS.FORCE_SYNC_PREPARE:
|
||||||
if (data.senderId) {
|
if (data.senderId) {
|
||||||
addToHistory(event, data.senderId);
|
addToHistory(event, data.senderId);
|
||||||
showNotification(data.senderId, event);
|
showNotification(event, data.senderId);
|
||||||
updateLastAction(event, data.senderId);
|
updateLastAction(event, data.senderId);
|
||||||
}
|
}
|
||||||
routeToContent(event, data);
|
routeToContent(event, data);
|
||||||
@@ -621,8 +621,14 @@ chrome.alarms.onAlarm.addListener(async (alarm) => {
|
|||||||
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
||||||
connect();
|
connect();
|
||||||
} else if (currentRoom) {
|
} else if (currentRoom) {
|
||||||
// Heartbeat Logic migrated from setInterval
|
// Heartbeat Logic: Always include identity metadata
|
||||||
emit(EVENTS.PEER_STATUS, { peerId, status: 'heartbeat' });
|
const settings = await getSettings();
|
||||||
|
emit(EVENTS.PEER_STATUS, {
|
||||||
|
peerId,
|
||||||
|
status: 'heartbeat',
|
||||||
|
username: settings.username,
|
||||||
|
tabTitle: currentTabTitle
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -635,7 +641,13 @@ setInterval(async () => {
|
|||||||
connect();
|
connect();
|
||||||
} else if (currentRoom) {
|
} else if (currentRoom) {
|
||||||
// Redundant heartbeat for active SW state
|
// Redundant heartbeat for active SW state
|
||||||
emit(EVENTS.PEER_STATUS, { peerId, status: 'heartbeat' });
|
const settings = await getSettings();
|
||||||
|
emit(EVENTS.PEER_STATUS, {
|
||||||
|
peerId,
|
||||||
|
status: 'heartbeat',
|
||||||
|
username: settings.username,
|
||||||
|
tabTitle: currentTabTitle
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}, 30000); // every 30s
|
}, 30000); // every 30s
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -347,11 +347,16 @@ function applyConnectionStatus(status) {
|
|||||||
// Update Join Button during auto-transition
|
// Update Join Button during auto-transition
|
||||||
if (connecting) {
|
if (connecting) {
|
||||||
elements.joinBtn.disabled = true;
|
elements.joinBtn.disabled = true;
|
||||||
elements.joinBtn.textContent = 'Connecting...';
|
elements.joinBtn.textContent = '🚀 Joining...';
|
||||||
} else {
|
} else {
|
||||||
elements.joinBtn.disabled = false;
|
elements.joinBtn.disabled = false;
|
||||||
elements.joinBtn.textContent = 'Join Room';
|
elements.joinBtn.textContent = 'Join Room';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Preserve icons for Remote Control buttons
|
||||||
|
elements.playBtn.textContent = '▶ Play';
|
||||||
|
elements.pauseBtn.textContent = '⏸ Pause';
|
||||||
|
elements.forceSyncBtn.textContent = '⚡ Force Sync Everyone';
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateHistory(history) {
|
function updateHistory(history) {
|
||||||
|
|||||||
Reference in New Issue
Block a user