Refactor code structure for improved readability and maintainability
All checks were successful
Build and Push Docker Image / docker (push) Successful in 21s
All checks were successful
Build and Push Docker Image / docker (push) Successful in 21s
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user