Browse Source

fix(Station): addPartyPlaylistSongToQueue only if queue is not full

Owen Diffey 3 years ago
parent
commit
9372b821da

+ 1 - 0
frontend/src/components/modals/ManageStation/Tabs/Playlists.vue

@@ -922,6 +922,7 @@ export default {
 			if (
 				this.station.type === "community" &&
 				this.station.partyMode === true &&
+				this.songsList.length < 50 &&
 				this.songsList.filter(
 					queueSong => queueSong.requestedBy === this.userId
 				).length < 3 &&

+ 1 - 0
frontend/src/pages/Station/Sidebar/Playlists.vue

@@ -277,6 +277,7 @@ export default {
 			if (
 				this.station.type === "community" &&
 				this.station.partyMode === true &&
+				this.songsList.length < 50 &&
 				this.songsList.filter(
 					queueSong => queueSong.requestedBy === this.userId
 				).length < 3 &&

+ 8 - 11
frontend/src/pages/Station/index.vue

@@ -899,7 +899,8 @@ export default {
 			beforeEditSongModalLocalPaused: null,
 			socketConnected: null,
 			persistentToastCheckerInterval: null,
-			persistentToasts: []
+			persistentToasts: [],
+			partyPlaylistLock: false
 		};
 	},
 	computed: {
@@ -964,16 +965,6 @@ export default {
 			socket: "websockets/getSocket"
 		})
 	},
-	watch: {
-		currentUserQueueSongs(total) {
-			if (
-				this.station.type === "community" &&
-				this.station.partyMode === true &&
-				total < 3
-			)
-				this.addPartyPlaylistSongToQueue();
-		}
-	},
 	async mounted() {
 		this.editSongModalWatcher = this.$store.watch(
 			state => state.modals.editSong.video.paused,
@@ -1143,6 +1134,8 @@ export default {
 					: null;
 
 			this.updateNextSong(nextSong);
+
+			if (res.data.queue.length < 50) this.addPartyPlaylistSongToQueue();
 		});
 
 		this.socket.on("event:station.queue.song.repositioned", res => {
@@ -1919,8 +1912,10 @@ export default {
 		},
 		addPartyPlaylistSongToQueue() {
 			if (
+				!this.partyPlaylistLock &&
 				this.station.type === "community" &&
 				this.station.partyMode === true &&
+				this.songsList.length < 50 &&
 				this.currentUserQueueSongs < 3 &&
 				this.partyPlaylists.length > 0
 			) {
@@ -1936,11 +1931,13 @@ export default {
 							)
 						];
 					if (selectedSong.youtubeId) {
+						this.partyPlaylistLock = true;
 						this.socket.dispatch(
 							"stations.addToQueue",
 							this.station._id,
 							selectedSong.youtubeId,
 							data => {
+								this.partyPlaylistLock = false;
 								if (data.status !== "success")
 									this.addPartyPlaylistSongToQueue();
 							}