Преглед изворни кода

Fixed issue where excluding playlist wouldn't wait for removing included playlist

Kristian Vos пре 3 година
родитељ
комит
b191abdb3c
1 измењених фајлова са 30 додато и 22 уклоњено
  1. 30 22
      frontend/src/components/modals/ManageStation/Tabs/Playlists.vue

+ 30 - 22
frontend/src/components/modals/ManageStation/Tabs/Playlists.vue

@@ -434,29 +434,37 @@ export default {
 			}
 		},
 		deselectPlaylist(id) {
-			if (this.station.type === "community" && this.station.partyMode) {
-				let selected = false;
-				this.currentPlaylists.forEach((playlist, index) => {
-					if (playlist._id === id) {
-						selected = true;
-						this.partyPlaylists.splice(index, 1);
+			return new Promise(resolve => {
+				if (
+					this.station.type === "community" &&
+					this.station.partyMode
+				) {
+					let selected = false;
+					this.currentPlaylists.forEach((playlist, index) => {
+						if (playlist._id === id) {
+							selected = true;
+							this.partyPlaylists.splice(index, 1);
+						}
+					});
+					if (selected) {
+						new Toast("Successfully deselected playlist.");
+						resolve();
+					} else {
+						new Toast("Playlist not selected.");
+						resolve();
 					}
-				});
-				if (selected) {
-					new Toast("Successfully deselected playlist.");
 				} else {
-					new Toast("Playlist not selected.");
+					this.socket.dispatch(
+						"stations.removeIncludedPlaylist",
+						this.station._id,
+						id,
+						res => {
+							new Toast(res.message);
+							resolve();
+						}
+					);
 				}
-			} else {
-				this.socket.dispatch(
-					"stations.removeIncludedPlaylist",
-					this.station._id,
-					id,
-					res => {
-						new Toast(res.message);
-					}
-				);
-			}
+			});
 		},
 		isSelected(id) {
 			let selected = false;
@@ -514,8 +522,8 @@ export default {
 				}
 			});
 		},
-		blacklistPlaylist(id) {
-			if (this.isSelected(id)) this.deselectPlaylist(id);
+		async blacklistPlaylist(id) {
+			if (this.isSelected(id)) await this.deselectPlaylist(id);
 
 			this.socket.dispatch(
 				"stations.excludePlaylist",