Browse Source

Fixed issues with Kris's refactor

theflametrooper 8 years ago
parent
commit
70233c4ef6
2 changed files with 10 additions and 16 deletions
  1. 4 7
      backend/logic/songs.js
  2. 6 9
      backend/logic/stations.js

+ 4 - 7
backend/logic/songs.js

@@ -23,11 +23,10 @@ module.exports = {
 				if (!songs) return next();
 				let songIds = Object.keys(songs);
 				async.each(songIds, (songId, next) => {
-					db.models.song.findOne({_id: songId}, (err, song) => {
+					db.models.song.findOne({ _id: songId }, (err, song) => {
 						if (err) next(err);
-						else if (!song) {
-							cache.hdel('songs', songId, next);
-						}
+						else if (!song) cache.hdel('songs', songId, next);
+						else next();
 					});
 				}, next);
 			},
@@ -45,9 +44,7 @@ module.exports = {
 			if (err) {
 				console.log(`FAILED TO INITIALIZE SONGS. ABORTING. "${err.message}"`);
 				process.exit();
-			} else {
-				cb();
-			}
+			} else cb();
 		});
 	},
 

+ 6 - 9
backend/logic/stations.js

@@ -78,14 +78,12 @@ module.exports = {
 			if (err) {
 				console.log(`FAILED TO INITIALIZE STATIONS. ABORTING. "${err.message}"`);
 				process.exit();
-			} else {
-				cb();
-			}
+			} else cb();
 		});
 	},
 
 	initializeStation: function(stationId, cb) {
-		if (typeof cb !== 'function') cb = ()=>{};
+		if (typeof cb !== 'function') cb = () => {};
 		async.waterfall([
 			(next) => {
 				this.getStation(stationId, next);
@@ -107,13 +105,12 @@ module.exports = {
 					this.calculateOfficialPlaylistList(stationId, station.playlist, () => {
 						next(station);
 					});
-				} else next();
+				} else next(station);
 			},
 
 			(station, next) => {
-				if (!station.paused ) {
-
-				} else {
+				if (!station.paused) next(true, station);
+				else {
 					notifications.unschedule(`stations.nextSong?id${station._id}`);
 					next(true, station);
 				}
@@ -136,7 +133,7 @@ module.exports = {
 					this.skipStation(station._id)(next);
 				}
 			}
-		], (err, station) => {
+		], (station, err) => {
 			if (err && err !== true) {
 				let error = 'An error occurred.';
 				if (typeof err === "string") error = err;