fix: resolve metadata desync in heartbeats and restore remote control icons

This commit is contained in:
Timo
2026-04-22 13:33:33 +02:00
parent 622db23f38
commit e65c326c32
2 changed files with 22 additions and 5 deletions
+16 -4
View File
@@ -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
View File
@@ -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) {