Browse Source

Fixed private stations select buttons not live updating.

KrisVos130 8 years ago
parent
commit
a65ef84f40
2 changed files with 14 additions and 1 deletions
  1. 8 1
      backend/logic/actions/stations.js
  2. 6 0
      frontend/components/Station/Station.vue

+ 8 - 1
backend/logic/actions/stations.js

@@ -13,6 +13,11 @@ const stations = require('../stations');
 const songs = require('../songs');
 const hooks = require('./hooks');
 
+cache.sub('privatePlaylist.selected', data => {
+	console.log(data);
+	utils.emitToRoom(`station.${data.stationId}`, "event:privatePlaylist.selected", data.playlistId);
+});
+
 cache.sub('station.pause', stationId => {
 	utils.emitToRoom(`station.${stationId}`, "event:stations.pause");
 });
@@ -214,7 +219,8 @@ module.exports = {
 								displayName: station.displayName,
 								privacy: station.privacy,
 								partyMode: station.partyMode,
-								owner: station.owner
+								owner: station.owner,
+								privatePlaylist: station.privatePlaylist
 							}
 						});
 					}
@@ -546,6 +552,7 @@ module.exports = {
 							stations.updateStation(stationId, (err, station) => {
 								if (err) return cb(err);
 								stations.skipStation(stationId)();
+								cache.pub('privatePlaylist.selected', {playlistId, stationId});
 								cb({'status': 'success', 'message': 'Playlist selected.'});
 							});
 						});

+ 6 - 0
frontend/components/Station/Station.vue

@@ -462,6 +462,12 @@
 						this.currentSong.skipVotes++;
 					}
 				});
+
+				_this.socket.on('event:privatePlaylist.selected', (playlistId) => {
+					if (this.type === 'community') {
+						this.station.privatePlaylist = playlistId;
+					}
+				});
 			});
 
 			let volume = parseInt(localStorage.getItem("volume"));