Browse Source

Worked on integrating official playlists with backend and frontend

theflametrooper 8 years ago
parent
commit
35beb12733
2 changed files with 15 additions and 7 deletions
  1. 5 5
      backend/logic/actions/stations.js
  2. 10 2
      frontend/components/Sidebars/OfficialQueue.vue

+ 5 - 5
backend/logic/actions/stations.js

@@ -132,17 +132,17 @@ module.exports = {
 	},
 
 	getPlaylist: (session, stationId, cb) => {
-		let playlist = [];
-
 		stations.getStation(stationId, (err, station) => {
-			for (let s = 1; s < station.playlist.length; s++) {
+			let playlist = [];
+
+			for (let s = 0; s < station.playlist.length; s++) {
 				songs.getSong(station.playlist[s], (err, song) => {
 					playlist.push(song);
 				});
 			}
-		});
 
-		cb({ status: 'success', data: playlist })
+			cb({ status: 'success', data: playlist });
+		});
 	},
 
 	/**

+ 10 - 2
frontend/components/Sidebars/OfficialQueue.vue

@@ -23,7 +23,7 @@
 				</div>
 			</article>
 
-			<article class="media" v-for='song in $parent.queue'>
+			<article class="media" v-for='song in playlist'>
 				<div class="media-content">
 					<div class="content">
 						<p>
@@ -42,11 +42,19 @@
 	import io from '../../io';
 
 	export default {
+		data: function () {
+			return {
+				playlist: []
+			}
+		},
 		ready: function () {
 			let _this = this;
 			io.getSocket((socket) => {
 				_this.socket = socket;
-				// get official station playlist
+				_this.socket.emit('stations.getPlaylist', _this.$parent.stationId, res => {
+					console.log(res);
+					if (res.status == 'success') _this.playlist = res.data;
+				});
 			});
 		}
 	}