mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-07-28 12:59:45 +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:
|
||||
if (data.senderId) {
|
||||
addToHistory(event, data.senderId);
|
||||
showNotification(data.senderId, event);
|
||||
showNotification(event, data.senderId);
|
||||
updateLastAction(event, data.senderId);
|
||||
}
|
||||
routeToContent(event, data);
|
||||
@@ -621,8 +621,14 @@ chrome.alarms.onAlarm.addListener(async (alarm) => {
|
||||
if (!socket || socket.readyState !== WebSocket.OPEN) {
|
||||
connect();
|
||||
} else if (currentRoom) {
|
||||
// Heartbeat Logic migrated from setInterval
|
||||
emit(EVENTS.PEER_STATUS, { peerId, status: 'heartbeat' });
|
||||
// Heartbeat Logic: Always include identity metadata
|
||||
const settings = await getSettings();
|
||||
emit(EVENTS.PEER_STATUS, {
|
||||
peerId,
|
||||
status: 'heartbeat',
|
||||
username: settings.username,
|
||||
tabTitle: currentTabTitle
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -635,7 +641,13 @@ setInterval(async () => {
|
||||
connect();
|
||||
} else if (currentRoom) {
|
||||
// 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
|
||||
|
||||
|
||||
+6
-1
@@ -347,11 +347,16 @@ function applyConnectionStatus(status) {
|
||||
// Update Join Button during auto-transition
|
||||
if (connecting) {
|
||||
elements.joinBtn.disabled = true;
|
||||
elements.joinBtn.textContent = 'Connecting...';
|
||||
elements.joinBtn.textContent = '🚀 Joining...';
|
||||
} else {
|
||||
elements.joinBtn.disabled = false;
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user