Browse Source

Fixed small typo and some minor syntax changes

theflametrooper 8 years ago
parent
commit
b15ab228a5

+ 3 - 5
backend/logic/actions/playlists.js

@@ -145,11 +145,9 @@ let lib = {
 
 					let found = false;
 					playlist.songs.forEach((song) => {
-						if (songId === song._id) {
-							found = true;
-						}
+						if (songId === song._id) found = true;
 					});
-					if (found) return next('That song is already in the playlist.');
+					if (found) return next('That song is already in the playlist');
 					return next(null);
 				});
 			},
@@ -184,7 +182,7 @@ let lib = {
 		(err, playlist, newSong) => {
 			if (err) return cb({ status: 'error', message: err });
 			else if (playlist.songs) {
-				cache.pub('playlist.addSong', {playlistId: playlist._id, song: newSong, userId: userId});
+				cache.pub('playlist.addSong', { playlistId: playlist._id, song: newSong, userId: userId });
 				return cb({ status: 'success', message: 'Song has been successfully added to the playlist', data: playlist.songs });
 			}
 		});

+ 14 - 21
backend/logic/actions/stations.js

@@ -27,7 +27,7 @@ cache.sub('station.pause', stationId => {
 
 cache.sub('station.resume', stationId => {
 	stations.getStation(stationId, (err, station) => {
-		utils.emitToRoom(`station.${stationId}`, "event:stations.resume", {timePaused: station.timePaused});
+		utils.emitToRoom(`station.${stationId}`, "event:stations.resume", { timePaused: station.timePaused });
 	});
 });
 
@@ -376,24 +376,19 @@ module.exports = {
 
 	resume: hooks.ownerRequired((session, stationId, cb) => {
 		stations.getStation(stationId, (err, station) => {
-			if (err && err !== true) {
-				return cb({ status: 'error', message: 'An error occurred while resuming the station' });
-			} else if (station) {
+			if (err && err !== true) return cb({ status: 'error', message: 'An error occurred while resuming the station' });
+			else if (station) {
 				if (station.paused) {
 					station.paused = false;
 					station.timePaused += (Date.now() - station.pausedAt);
-					db.models.station.update({_id: stationId}, {$set: {paused: false}, $inc: {timePaused: Date.now() - station.pausedAt}}, () => {
+					db.models.station.update({ _id: stationId }, { $set: { paused: false }, $inc: { timePaused: Date.now() - station.pausedAt } }, () => {
 						stations.updateStation(stationId, (err, station) => {
 							cache.pub('station.resume', stationId);
 							cb({ status: 'success' });
 						});
 					});
-				} else {
-					cb({ status: 'failure', message: 'That station is not paused.' });
-				}
-			} else {
-				cb({ status: 'failure', message: `That station doesn't exist, it may have been deleted` });
-			}
+				} else cb({ status: 'failure', message: 'That station is not paused.' });
+			} else cb({ status: 'failure', message: `That station doesn't exist, it may have been deleted` });
 		});
 	}),
 
@@ -473,13 +468,11 @@ module.exports = {
 			if (err) return cb(err);
 			if (station.type === 'community') {
 				let has = false;
-				station.queue.forEach((queueSong) => {
-					if (queueSong._id === songId) {
-						has = true;
-					}
+				station.queue.forEach(queueSong => {
+					if (queueSong._id === songId) has = true;
 				});
-				if (has) return cb({'status': 'failure', 'message': 'That song has already been added to the queue.'});
-				if (station.currentSong && station.currentSong._id === songId) return cb({'status': 'failure', 'message': 'That song is currently playing.'});
+				if (has) return cb({'status': 'failure', 'message': 'That song has already been added to the queue'});
+				if (station.currentSong && station.currentSong._id === songId) return cb({'status': 'failure', 'message': 'That song is currently playing'});
 
 				songs.getSong(songId, (err, song) => {
 					if (err) {
@@ -494,17 +487,17 @@ module.exports = {
 						});
 					} else cont(song);
 					function cont(song) {
-						db.models.station.update({_id: stationId}, {$push: {queue: song}}, (err) => {
-							if (err) return cb({'status': 'failure', 'message': 'Something went wrong.'});
+						db.models.station.update({ _id: stationId }, { $push: { queue: song } }, (err) => {
+							if (err) return cb({'status': 'failure', 'message': 'Something went wrong'});
 							stations.updateStation(stationId, (err, station) => {
 								if (err) return cb(err);
 								cache.pub('station.queueUpdate', stationId);
-								cb({'status': 'success', 'message': 'Added that song to the queue.'});
+								cb({ 'status': 'success', 'message': 'Added that song to the queue' });
 							});
 						});
 					}
 				});
-			} else cb({'status': 'failure', 'message': 'That station is not a community station.'});
+			} else cb({'status': 'failure', 'message': 'That station is not a community station'});
 		});
 	}),
 

+ 2 - 2
backend/logic/stations.js

@@ -75,7 +75,7 @@ module.exports = {
 						notifications.unschedule(`stations.nextSong?id${station._id}`);
 						cb(null, station);
 					}
-				} else cb("Station not found.");
+				} else cb("Station not found");
 			} else cb(err);
 		});
 	},
@@ -163,7 +163,7 @@ module.exports = {
 			},
 
 			(station, next) => {
-				if (!station) return next('Station not found.');
+				if (!station) return next('Station not found');
 				cache.hset('stations', stationId, station, (err) => {
 					if (err) return next(err);
 					next(null, station);

+ 4 - 10
frontend/components/Modals/AddSongToQueue.vue

@@ -86,19 +86,13 @@
 				let _this = this;
 				if (_this.$parent.type === 'community') {
 					_this.socket.emit('stations.addToQueue', _this.$parent.stationId, songId, data => {
-						if (data.status !== 'success') {
-							Toast.methods.addToast(`Error: ${data.message}`, 8000);
-						} else {
-							Toast.methods.addToast(`${data.message}`, 4000);
-						}
+						if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
+						else Toast.methods.addToast(`${data.message}`, 4000);
 					});
 				} else {
 					_this.socket.emit('queueSongs.add', songId, data => {
-						if (data.status !== 'success') {
-							Toast.methods.addToast(`Error: ${data.message}`, 8000);
-						} else {
-							Toast.methods.addToast(`${data.message}`, 4000);
-						}
+						if (data.status !== 'success') Toast.methods.addToast(`Error: ${data.message}`, 8000);
+						else Toast.methods.addToast(`${data.message}`, 4000);
 					});
 				}
 			},

+ 1 - 1
frontend/components/Modals/Register.vue

@@ -21,7 +21,7 @@
 					<input class='input' type='password' placeholder='Password...' v-model='$parent.register.password' v-on:keypress='$parent.submitOnEnter(submitModal, $event)'>
 				</p>
 				<div id="recaptcha"></div>
-				<p>By logging in you agree to our <a href="/terms" v-link="{ path: '/terms' }">Terms of Service</a> and <a href="/privacy" v-link="{ path: '/privacy' }">Privacy Policy</a>.</p>
+				<p>By registering you agree to our <a href="/terms" v-link="{ path: '/terms' }">Terms of Service</a> and <a href="/privacy" v-link="{ path: '/privacy' }">Privacy Policy</a>.</p>
 			</section>
 			<footer class='modal-card-foot'>
 				<a class='button is-primary' @click='submitModal()' href='#'>Submit</a>

+ 1 - 3
frontend/components/Station/Station.vue

@@ -302,9 +302,7 @@
 							_this.socket.emit('stations.addToQueue', _this.stationId, songId, data => {
 								if (data.status === 'success') {
 									_this.socket.emit('playlists.moveSongToBottom', _this.privatePlaylistQueueSelected, songId, data => {
-										if (data.status === 'success') {
-											console.log("Added first song to queue!");
-										}
+										if (data.status === 'success') {}
 									});
 								}
 							});