Browse Source

Added backend for playlist updating, and fixed error.

KrisVos130 8 years ago
parent
commit
ed3d612cf4
1 changed files with 10 additions and 1 deletions
  1. 10 1
      backend/logic/stations.js

+ 10 - 1
backend/logic/stations.js

@@ -26,6 +26,14 @@ cache.sub('station.queueUpdate', (stationId) => {
 	});
 });
 
+cache.sub('station.newOfficialPlaylist', (stationId) => {
+	cache.hget("officialPlaylists", stationId, (err, playlistObj) => {
+		if (!err && !playlistObj) {
+			utils.emitToRoom(`station.${stationId}`, "event:newOfficialPlaylist", playlistObj.songs);
+		}
+	})
+});
+
 module.exports = {
 
 	init: function(cb) {
@@ -122,7 +130,7 @@ module.exports = {
 				});
 			},
 
-			(playlist, lessInfoPlaylist, next) => {
+			(playlist, next) => {
 				db.models.station.update({_id: station._id}, {$set: {playlist: playlist}}, (err) => {
 					_this.updateStation(station._id, () => {
 						next(err, playlist);
@@ -210,6 +218,7 @@ module.exports = {
 				})
 			} else {
 				cache.hset("officialPlaylists", stationId, cache.schemas.officialPlaylist(stationId, lessInfoPlaylist), () => {
+					cache.pub("station.newOfficialPlaylist", stationId);
 					cb();
 				});
 			}