mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-20 16:12:16 +00:00
feat(extension): send nothing to the server while alone in a room
When no other peer is present, heartbeats, force-sync, and episode auto-sync are now fully suppressed (previously the keepAlive heartbeat, force-sync, and episode lobby were still broadcast to an empty room): - keepAlive heartbeat gated on a live peer count - force-sync is a no-op when solo (no pause-then-timeout freeze, no traffic) - episode auto-sync skips the lobby entirely and just plays the next episode The solo state is recomputed live from the current peer list on every event (never cached), so the instant another peer joins syncing resumes. On that solo->not-solo transition the background also requests an immediate heartbeat from the content script so the newcomer sees the current position without waiting for the next interval. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -538,6 +538,14 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
// Background asks for an immediate state push (e.g. the first peer just
|
||||
// joined while we were solo) so the newcomer syncs without waiting.
|
||||
if (message.type === 'REQUEST_HEARTBEAT') {
|
||||
sendHeartbeat();
|
||||
sendResponse({ ok: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
if (message.type === 'SERVER_COMMAND') {
|
||||
const { action, payload } = message;
|
||||
let actionCompleted = false;
|
||||
|
||||
Reference in New Issue
Block a user