Browse Source

fix: backend exception if an empty playlist updated

Kristian Vos 2 years ago
parent
commit
7d4062efc6
1 changed files with 6 additions and 3 deletions
  1. 6 3
      backend/logic/actions/playlists.js

+ 6 - 3
backend/logic/actions/playlists.js

@@ -244,9 +244,12 @@ CacheModule.runJob("SUB", {
 				const newPlaylist = {
 				const newPlaylist = {
 					...playlist._doc,
 					...playlist._doc,
 					songsCount: playlist.songs.length,
 					songsCount: playlist.songs.length,
-					songsLength: playlist.songs.reduce((previous, current) => ({
-						duration: previous.duration + current.duration
-					})).duration
+					songsLength: playlist.songs.reduce(
+						(previous, current) => ({
+							duration: previous.duration + current.duration
+						}),
+						{ duration: 0 }
+					).duration
 				};
 				};
 				delete newPlaylist.songs;
 				delete newPlaylist.songs;
 				WSModule.runJob("EMIT_TO_ROOMS", {
 				WSModule.runJob("EMIT_TO_ROOMS", {