浏览代码

Fixed a lot of issues with songs list and other issues.

KrisVos130 8 年之前
父节点
当前提交
d5872505ed

+ 1 - 1
backend/logic/actions/hooks/ownerRequired.js

@@ -15,7 +15,7 @@ module.exports = function(next) {
 				else {
 					stations.getStation(stationId, (err, station) => {
 						if (err || !station) return cb({ status: 'failure', message: 'Something went wrong when getting the station.' });
-						else if (station.type === 'community' && station.owner === session.userId) func();
+						else if (station.type === 'community' && station.owner === session.userId) pushArgs();
 						else return cb({ status: 'failure', message: 'Invalid permissions.' });
 					});
 				}

+ 1 - 1
backend/logic/actions/songs.js

@@ -96,7 +96,7 @@ module.exports = {
 						console.error(err);
 						cb({ status: 'failure', message: 'Something went wrong while adding the song to the queue.' });
 					} else {
-						cache.pub('song.added', songId);
+						cache.pub('song.added', song._id);
 						cb({ status: 'success', message: 'Song has been moved from Queue' });
 					}
 				});

+ 2 - 5
backend/logic/stations.js

@@ -28,7 +28,7 @@ cache.sub('station.queueUpdate', (stationId) => {
 
 cache.sub('station.newOfficialPlaylist', (stationId) => {
 	cache.hget("officialPlaylists", stationId, (err, playlistObj) => {
-		if (!err && !playlistObj) {
+		if (!err && playlistObj) {
 			utils.emitToRoom(`station.${stationId}`, "event:newOfficialPlaylist", playlistObj.songs);
 		}
 	})
@@ -184,9 +184,6 @@ module.exports = {
 
 			(station, next) => {
 				if (!station) return next('Station not found');
-				if (station.type === 'official') {
-					_this.calculateOfficialPlaylistList(station._id, station.playlist, ()=>{});
-				}
 				cache.hset('stations', stationId, station, (err) => {
 					if (err) return next(err);
 					next(null, station);
@@ -303,7 +300,7 @@ module.exports = {
 										}
 									}
 
-									func();
+									setCurrentSong();
 								} else {
 									_this.calculateSongForStation(station, (err, playlist) => {
 										if (!err && playlist.length === 0) {

+ 4 - 0
frontend/App.vue

@@ -138,6 +138,10 @@
 <style type='scss'>
 	#toast-container { z-index: 10000 !important; }
 
+	html {
+		overflow: auto !important;
+	}
+
 	.absolute-a {
 		width: 100%;
 		height: 100%;

+ 21 - 8
frontend/components/Sidebars/SongsList.vue

@@ -4,7 +4,7 @@
 			<div class='title' v-if='$parent.type === "community"'>Queue</div>
 			<div class='title' v-else>Playlist</div>
 
-			<article class="media">
+			<article class="media" v-if="!$parent.noSong">
 				<figure class="media-left">
 					<p class="image is-64x64">
 						<img :src="$parent.currentSong.thumbnail" onerror="this.src='/assets/notes-transparent.png'">
@@ -24,7 +24,7 @@
 				</div>
 			</article>
 
-			<article class="media" v-for='song in playlist'>
+			<article class="media" v-for='song in $parent.songsList'>
 				<div class="media-content">
 					<div class="content">
 						<p>
@@ -38,6 +38,7 @@
 					{{ $parent.$parent.formatTime(song.duration) }}
 				</div>
 			</article>
+			<a class='button add-to-queue' href='#' @click='$parent.modals.addSongToQueue = !$parent.modals.addSongToQueue' v-if="$parent.type === 'community'">Add Song to Queue</a>
 		</div>
 	</div>
 </template>
@@ -48,17 +49,15 @@
 	export default {
 		data: function () {
 			return {
-				playlist: []
+
 			}
 		},
 		ready: function () {
-			let _this = this;
+			/*let _this = this;
 			io.getSocket((socket) => {
 				_this.socket = socket;
-				_this.socket.emit('stations.getPlaylist', _this.$parent.stationId, res => {
-					if (res.status == 'success') _this.playlist = res.data;
-				});
-			});
+
+			});*/
 		}
 	}
 </script>
@@ -78,6 +77,8 @@
 	.inner-wrapper {	
 		top: 64px;
 		position: relative;
+		overflow: auto;
+		height: 100%;
 	}
 
 	.slide-transition {
@@ -105,5 +106,17 @@
 		strong { word-break: break-word; }
 	}
 
+	.add-to-queue {
+		width: 100%;
+		margin-top: 25px;
+		height: 40px;
+		border-radius: 0;
+		background: rgb(3, 169, 244);
+		color: #fff !important;
+		border: 0;
+		&:active, &:focus { border: 0; }
+	}
+	.add-to-queue:focus { background: #029ce3; }
+
 	.media-right { line-height: 64px; }
 </style>

+ 34 - 21
frontend/components/Station/Station.vue

@@ -117,7 +117,7 @@
 				},
 				noSong: false,
 				simpleSong: false,
-				queue: [],
+				songsList: [],
 				timeBeforePause: 0,
 				station: {},
 				skipVotes: 0,
@@ -289,24 +289,26 @@
 				let _this = this;
 				let isInQueue = false;
 				let userId = _this.$parent.userId;
-				_this.queue.forEach((queueSong) => {
-					if (queueSong.requestedBy === userId) isInQueue = true;
-				});
-				if (!isInQueue && _this.privatePlaylistQueueSelected) {
-
-					_this.socket.emit('playlists.getFirstSong', _this.privatePlaylistQueueSelected, data => {
-						if (data.status === 'success') {
-							let songId = data.song._id;
-							_this.automaticallyRequestedSongId = songId;
-							_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') {}
-									});
-								}
-							});
-						}
+				if (_this.type === 'community') {
+					_this.songsList.forEach((queueSong) => {
+						if (queueSong.requestedBy === userId) isInQueue = true;
 					});
+					if (!isInQueue && _this.privatePlaylistQueueSelected) {
+
+						_this.socket.emit('playlists.getFirstSong', _this.privatePlaylistQueueSelected, data => {
+							if (data.status === 'success') {
+								let songId = data.song._id;
+								_this.automaticallyRequestedSongId = songId;
+								_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') {}
+										});
+									}
+								});
+							}
+						});
+					}
 				}
 			},
 			joinStation: function () {
@@ -346,10 +348,14 @@
 						}
 						if (_this.type === 'community') {
 							_this.socket.emit('stations.getQueue', _this.stationId, data => {
-								if (data.status === 'success') _this.queue = data.queue;
+								if (data.status === 'success') _this.songsList = data.queue;
 							});
 						}
 					}
+
+					_this.socket.emit('stations.getPlaylist', _this.stationId, res => {
+				 		if (res.status == 'success') _this.songsList = res.data;
+				 	});
 				});
 			}
 		},
@@ -400,7 +406,7 @@
 
 					let isInQueue = false;
 					let userId = _this.$parent.userId;
-					_this.queue.forEach((queueSong) => {
+					_this.songsList.forEach((queueSong) => {
 						if (queueSong.requestedBy === userId) isInQueue = true;
 					});
 					if (!isInQueue && _this.privatePlaylistQueueSelected && (_this.automaticallyRequestedSongId !== _this.currentSong._id || !_this.currentSong._id)) {
@@ -457,7 +463,7 @@
 				});
 
 				_this.socket.on('event:queue.update', queue => {
-					if (this.type === 'community') this.queue = queue;
+					if (this.type === 'community') this.songsList = queue;
 				});
 
 				_this.socket.on('event:song.voteSkipSong', () => {
@@ -475,6 +481,13 @@
 						this.station.partyMode = partyMode;
 					}
 				});
+
+				_this.socket.on('event:newOfficialPlaylist', (playlist) => {
+					console.log(playlist);
+					if (this.type === 'official') {
+						this.songsList = playlist;
+					}
+				});
 			});