Refactor code structure for improved readability and maintainability
All checks were successful
Build and Push Docker Image / docker (push) Successful in 21s

This commit is contained in:
2025-09-04 21:53:54 +02:00
parent 80f8c4ca90
commit 8c5ca0044f
27 changed files with 3398 additions and 326 deletions

View File

@@ -3,11 +3,20 @@ import { broadcast } from './state.js';
export function startSyncTimer(room) {
if (room.syncTimer) clearInterval(room.syncTimer);
room.syncTimer = setInterval(() => {
if (room.state.status !== 'playing' || !room.state.currentTrack || !room.state.trackStartAt || room.state.paused) return;
if (
room.state.status !== 'playing' ||
!room.state.currentTrack ||
!room.state.trackStartAt ||
room.state.paused
)
return;
broadcast(room, 'sync', { startAt: room.state.trackStartAt, serverNow: Date.now() });
}, 1000);
}
export function stopSyncTimer(room) {
if (room.syncTimer) { clearInterval(room.syncTimer); room.syncTimer = null; }
if (room.syncTimer) {
clearInterval(room.syncTimer);
room.syncTimer = null;
}
}