Преглед изворни кода

Fixed checkStationSkip task.

KrisVos130 пре 7 година
родитељ
комит
5f742cb836
1 измењених фајлова са 4 додато и 1 уклоњено
  1. 4 1
      backend/logic/stations.js

+ 4 - 1
backend/logic/stations.js

@@ -9,6 +9,8 @@ const songs = require('./songs');
 const notifications = require('./notifications');
 const async = require('async');
 
+let subscription = null;
+
 let initialized = false;
 let lockdown = false;
 
@@ -104,7 +106,8 @@ module.exports = {
 			(station, next) => {
 				if (!station) return next('Station not found.');
 				notifications.unschedule(`stations.nextSong?id=${station._id}`);
-				notifications.subscribe(`stations.nextSong?id=${station._id}`, _this.skipStation(station._id), true, station);
+				if (subscription) notifications.remove(subscription);
+				subscription = notifications.subscribe(`stations.nextSong?id=${station._id}`, _this.skipStation(station._id), true, station);
 				if (station.paused) return next(true, station);
 				next(null, station);
 			},