소스 검색

fix(useSortablePlaylists): Error thrown if another users playlist was updated

Owen Diffey 1 년 전
부모
커밋
f7238f6547
1개의 변경된 파일11개의 추가작업 그리고 2개의 파일을 삭제
  1. 11 2
      frontend/src/composables/useSortablePlaylists.ts

+ 11 - 2
frontend/src/composables/useSortablePlaylists.ts

@@ -162,11 +162,20 @@ export function useSortablePlaylists() {
 		socket.on(
 			"event:user.orderOfPlaylists.updated",
 			res => {
+				const order = res.data.order.filter(playlistId =>
+					playlists.value.find(
+						playlist =>
+							playlist._id === playlistId &&
+							(isCurrentUser.value ||
+								playlist.privacy === "public")
+					)
+				);
 				const sortedPlaylists = [];
 
 				playlists.value.forEach(playlist => {
-					sortedPlaylists[res.data.order.indexOf(playlist._id)] =
-						playlist;
+					const playlistOrder = order.indexOf(playlist._id);
+					if (playlistOrder >= 0)
+						sortedPlaylists[playlistOrder] = playlist;
 				});
 
 				playlists.value = sortedPlaylists;