Browse Source

Got the queue list on station pages working for official stations (not permanent)

Kristian Vos 4 years ago
parent
commit
cc691c20fd
2 changed files with 30 additions and 3 deletions
  1. 7 3
      backend/logic/actions/stations.js
  2. 23 0
      frontend/src/pages/Station/index.vue

+ 7 - 3
backend/logic/actions/stations.js

@@ -2913,7 +2913,6 @@ export default {
 
 				(station, next) => {
 					if (!station) return next("Station not found.");
-					if (station.type !== "community") return next("Station is not a community station.");
 					return next(null, station);
 				},
 
@@ -2924,9 +2923,14 @@ export default {
 							return next("Insufficient permissions.");
 						})
 						.catch(err => next(err));
+				},
+
+				(station, next) => {
+					if (station.type === "official") next(null, station.playlist);
+					else next(null, station.queue);
 				}
 			],
-			async (err, station) => {
+			async (err, queue) => {
 				if (err) {
 					err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
 					this.log(
@@ -2942,7 +2946,7 @@ export default {
 				return cb({
 					status: "success",
 					message: "Successfully got queue.",
-					queue: station.queue
+					queue
 				});
 			}
 		);

+ 23 - 0
frontend/src/pages/Station/index.vue

@@ -678,6 +678,18 @@ export default {
 				) {
 					this.addFirstPrivatePlaylistSongToQueue();
 				}
+
+				if (this.station.type === "official") {
+					this.socket.emit(
+						"stations.getQueue",
+						this.station._id,
+						res => {
+							if (res.status === "success") {
+								this.updateSongsList(res.queue);
+							}
+						}
+					);
+				}
 			});
 
 			this.socket.on("event:stations.pause", data => {
@@ -1501,6 +1513,17 @@ export default {
 						});
 					}
 
+					if (
+						(type === "community" && partyMode === true) ||
+						type === "official"
+					) {
+						this.socket.emit("stations.getQueue", _id, res => {
+							if (res.status === "success") {
+								this.updateSongsList(res.queue);
+							}
+						});
+					}
+
 					if (this.isOwnerOrAdmin()) {
 						keyboardShortcuts.registerShortcut(
 							"station.pauseResume",