Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected async onAddedSong(payload: StationTopic.AddPlaylistSongPayLoad) {
// Filter by stationId
if (payload.stationId === this.stationId) {
// Check if the song is already in the list
if (!this.player.playlist.some(song => song.id === payload.song.id)) {
this.player.playlist = [...this.player.playlist, PlaylistSong.fromSong(payload.song)];
if (!this.player.playing) {
await this.publish(StationTopic.UPDATE_PLAYER_SONG, { song: null });
setTimeout(this.startPlayer.bind(this), 5000);
}
}
}
}
downVotes?: string[]
): Promise {
const song = await super.update(
id,
songId,
title,
url,
creatorId,
stationId,
duration,
thumbnail,
isPlayed,
upVotes,
downVotes
);
return PlaylistSong.fromSong(song);
}
public async delete(id: string): Promise {
const song = await super.delete(id);
return PlaylistSong.fromSong(song);
}
public async findOne(id?: string): Promise {
const song = await super.findOne(id);
return PlaylistSong.fromSong(song);
}