浏览代码

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", {