소스 검색

Fixed duplicate items appearing when including/excluding playlists within manage station

Owen Diffey 3 년 전
부모
커밋
6ba0308ede
2개의 변경된 파일18개의 추가작업 그리고 4개의 파일을 삭제
  1. 10 2
      frontend/src/components/modals/ManageStation/index.vue
  2. 8 2
      frontend/src/pages/Station/Sidebar/Playlists.vue

+ 10 - 2
frontend/src/components/modals/ManageStation/index.vue

@@ -349,7 +349,11 @@ export default {
 					"event:station.includedPlaylist",
 					res => {
 						const { playlist } = res.data;
-						this.includedPlaylists.push(playlist);
+						const playlistIndex = this.includedPlaylists
+							.map(includedPlaylist => includedPlaylist._id)
+							.indexOf(playlist._id);
+						if (playlistIndex === -1)
+							this.includedPlaylists.push(playlist);
 					},
 					{ modal: "manageStation" }
 				);
@@ -358,7 +362,11 @@ export default {
 					"event:station.excludedPlaylist",
 					res => {
 						const { playlist } = res.data;
-						this.excludedPlaylists.push(playlist);
+						const playlistIndex = this.excludedPlaylists
+							.map(excludedPlaylist => excludedPlaylist._id)
+							.indexOf(playlist._id);
+						if (playlistIndex === -1)
+							this.excludedPlaylists.push(playlist);
 					},
 					{ modal: "manageStation" }
 				);

+ 8 - 2
frontend/src/pages/Station/Sidebar/Playlists.vue

@@ -141,12 +141,18 @@ export default {
 
 		this.socket.on("event:station.includedPlaylist", res => {
 			const { playlist } = res.data;
-			this.includedPlaylists.push(playlist);
+			const playlistIndex = this.includedPlaylists
+				.map(includedPlaylist => includedPlaylist._id)
+				.indexOf(playlist._id);
+			if (playlistIndex === -1) this.includedPlaylists.push(playlist);
 		});
 
 		this.socket.on("event:station.excludedPlaylist", res => {
 			const { playlist } = res.data;
-			this.excludedPlaylists.push(playlist);
+			const playlistIndex = this.excludedPlaylists
+				.map(excludedPlaylist => excludedPlaylist._id)
+				.indexOf(playlist._id);
+			if (playlistIndex === -1) this.excludedPlaylists.push(playlist);
 		});
 
 		this.socket.on("event:station.removedIncludedPlaylist", res => {