remove song end poll
This commit is contained in:
@@ -94,36 +94,9 @@ export class HomepageService extends BaseService<null> {
|
||||
}
|
||||
|
||||
this.lastPoll = newPoll;
|
||||
this.scheduleSongEndPoll(newPoll.tidal_current);
|
||||
return newPoll;
|
||||
}
|
||||
|
||||
private scheduleSongEndPoll(tidal: TidalGetCurrent | null): void {
|
||||
this.clearSongEndPoll();
|
||||
|
||||
if (!tidal || tidal.status === "paused") {
|
||||
return;
|
||||
}
|
||||
|
||||
const remainingSeconds = tidal.durationInSeconds - tidal.currentInSeconds;
|
||||
if (remainingSeconds > 0) {
|
||||
this.songEndTimeout = setTimeout(
|
||||
() => {
|
||||
this.songEndTimeout = null;
|
||||
this.getFullInformation();
|
||||
},
|
||||
(remainingSeconds + 1) * 1000,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private clearSongEndPoll(): void {
|
||||
if (this.songEndTimeout) {
|
||||
clearTimeout(this.songEndTimeout);
|
||||
this.songEndTimeout = null;
|
||||
}
|
||||
}
|
||||
|
||||
listenForClientChange(): void {
|
||||
this.sseService.onClientChange((clientChange: SseClientChangeEvent) => {
|
||||
if (clientChange.clientCount === 0) {
|
||||
@@ -149,6 +122,5 @@ export class HomepageService extends BaseService<null> {
|
||||
if (this.pollingInterval) {
|
||||
clearInterval(this.pollingInterval);
|
||||
}
|
||||
this.clearSongEndPoll();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user