Jelajahi Sumber

Fixed issues with Kris's commits

theflametrooper 8 tahun lalu
induk
melakukan
5fdfe389ff
2 mengubah file dengan 9 tambahan dan 18 penghapusan
  1. 4 8
      backend/logic/actions/stations.js
  2. 5 10
      backend/logic/stations.js

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

@@ -33,9 +33,7 @@ cache.sub('station.resume', stationId => {
 
 cache.sub('station.queueUpdate', stationId => {
 	stations.getStation(stationId, (err, station) => {
-		if (!err) {
-			utils.emitToRoom(`station.${stationId}`, "event:queue.update", station.queue);
-		}
+		if (!err) utils.emitToRoom(`station.${stationId}`, "event:queue.update", station.queue);
 	});
 });
 
@@ -538,16 +536,14 @@ module.exports = {
 			if (err) return cb(err);
 			if (station.type === 'community') {
 				if (station.privatePlaylist === playlistId) return cb({'status': 'failure', 'message': 'That playlist is already selected.'});
-				db.models.playlist.findOne({_id: playlistId}, (err, playlist) => {
+				db.models.playlist.findOne({ _id: playlistId }, (err, playlist) => {
 					if (err) return cb(err);
 					if (playlist) {
-						db.models.station.update({_id: stationId}, {$set: {privatePlaylist: playlistId, currentSongIndex: 0}}, (err) => {
+						db.models.station.update({_id: stationId}, { $set: { privatePlaylist: playlistId, currentSongIndex: 0 } }, (err) => {
 							if (err) return cb(err);
 							stations.updateStation(stationId, (err, station) => {
 								if (err) return cb(err);
-								if (!station.partyMode) {
-									stations.skipStation(stationId)();
-								}
+								if (!station.partyMode) stations.skipStation(stationId)();
 								cache.pub('privatePlaylist.selected', {playlistId, stationId});
 								cb({'status': 'success', 'message': 'Playlist selected.'});
 							});

+ 5 - 10
backend/logic/stations.js

@@ -289,23 +289,18 @@ module.exports = {
 									});
 								}
 							} else {
-								if (station.partyMode === true) {
-									if (station.queue.length > 0) {
-										db.models.station.update({_id: stationId}, {$pull: {queue: {_id: station.queue[0]._id}}}, (err) => {
+								if (station.partyMode === true) if (station.queue.length > 0) {
+										db.models.station.update({ _id: stationId }, { $pull: { queue: { _id: station.queue[0]._id } } }, (err) => {
 											if (err) return next(err);
 											let $set = {};
 											$set.currentSong = station.queue[0];
 											$set.startedAt = Date.now();
 											$set.timePaused = 0;
-											if (station.paused) {
-												$set.pausedAt = Date.now();
-											}
+											if (station.paused) $set.pausedAt = Date.now();
 											next(null, $set);
 										});
-									} else {
-										next(null, {currentSong: null});
-									}
-								} else {
+									} else next(null, {currentSong: null});
+								else {
 									db.models.playlist.findOne({_id: station.privatePlaylist}, (err, playlist) => {
 										if (err || !playlist) return next(null, {currentSong: null});
 										playlist = playlist.songs;