Jelajahi Sumber

Fixed checkStationSkip task.

KrisVos130 7 tahun lalu
induk
melakukan
76fe1695dc
2 mengubah file dengan 4 tambahan dan 5 penghapusan
  1. 2 4
      backend/logic/stations.js
  2. 2 1
      backend/logic/tasks.js

+ 2 - 4
backend/logic/stations.js

@@ -103,11 +103,9 @@ 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 (station.paused) {
-					notifications.unschedule(`stations.nextSong?id=${station._id}`);
-					return next(true, station);
-				}
+				if (station.paused) return next(true, station);
 				next(null, station);
 			},
 			(station, next) => {

+ 2 - 1
backend/logic/tasks.js

@@ -3,6 +3,7 @@
 const cache = require("./cache");
 const logger = require("./logger");
 const Stations = require("./stations");
+const notifications = require("./notifications");
 const async = require("async");
 let utils;
 let tasks = {};
@@ -29,7 +30,7 @@ let checkStationSkipTask = (callback) => {
 				if (timeElapsed <= station.currentSong.duration) return next2();
 				else {
 					logger.error("TASK_STATIONS_SKIP_CHECK", `Skipping ${station._id} as it should have skipped already.`);
-					Stations.skipStation(station._id);
+					Stations.initializeStation(station._id);
 					next2();
 				}
 			}, () => {