Преглед на файлове

fix: backend exception if an empty playlist updated

Kristian Vos преди 2 години
родител
ревизия
7d4062efc6
променени са 1 файла, в които са добавени 6 реда и са изтрити 3 реда
  1. 6 3
      backend/logic/actions/playlists.js

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

@@ -244,9 +244,12 @@ CacheModule.runJob("SUB", {
 				const newPlaylist = {
 					...playlist._doc,
 					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;
 				WSModule.runJob("EMIT_TO_ROOMS", {