mirror of
https://github.com/informaticker/discord-jellyfin-bot.git
synced 2024-11-25 02:51:57 +01:00
🐛 Fix crash with empty playlists (#128)
This commit is contained in:
parent
c01ac56061
commit
2141880b44
@ -94,10 +94,14 @@ export class PlayItemCommand {
|
||||
}
|
||||
|
||||
const tracks = await item.toTracks(this.jellyfinSearchService);
|
||||
this.logger.debug(`Extracted ${tracks.length} tracks from the search item`);
|
||||
const reducedDuration = tracks.reduce(
|
||||
(sum, item) => sum + item.duration,
|
||||
0,
|
||||
);
|
||||
this.logger.debug(
|
||||
`Adding ${tracks.length} tracks with a duration of ${reducedDuration} ticks`,
|
||||
);
|
||||
this.playbackService.getPlaylistOrDefault().enqueueTracks(tracks);
|
||||
|
||||
const remoteImage: RemoteImageInfo | undefined = tracks
|
||||
|
@ -84,6 +84,10 @@ export class Playlist {
|
||||
* @returns the new lendth of the tracks in the playlist
|
||||
*/
|
||||
enqueueTracks(tracks: Track[]) {
|
||||
if (tracks.length === 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.eventEmitter.emit('controls.playlist.tracks.enqueued', {
|
||||
count: tracks.length,
|
||||
activeTrack: this.activeTrackIndex,
|
||||
|
Loading…
Reference in New Issue
Block a user