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 (
 			if (
 				this.station.type === "community" &&
 				this.station.type === "community" &&
 				this.station.partyMode === true &&
 				this.station.partyMode === true &&
+				this.songsList.length < 50 &&
 				this.songsList.filter(
 				this.songsList.filter(
 					queueSong => queueSong.requestedBy === this.userId
 					queueSong => queueSong.requestedBy === this.userId
 				).length < 3 &&
 				).length < 3 &&

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

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

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

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