Ver código fonte

fix(Playlists): AddToPlaylist dropdown shouldn't allow adding to non user modifiable playlists

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 4 anos atrás
pai
commit
c30875846e

+ 4 - 2
backend/logic/actions/playlists.js

@@ -170,9 +170,10 @@ export default {
 	 * Gets all playlists for the user requesting it
 	 * Gets all playlists for the user requesting it
 	 *
 	 *
 	 * @param {object} session - the session object automatically added by socket.io
 	 * @param {object} session - the session object automatically added by socket.io
+	 * @param {boolean} showNonModifiablePlaylists - whether or not to show non modifiable playlists e.g. liked songs
 	 * @param {Function} cb - gets called with the result
 	 * @param {Function} cb - gets called with the result
 	 */
 	 */
-	indexForUser: isLoginRequired(async function indexForUser(session, cb) {
+	indexForUser: isLoginRequired(async function indexForUser(session, showNonModifiablePlaylists, cb) {
 		const playlistModel = await DBModule.runJob(
 		const playlistModel = await DBModule.runJob(
 			"GET_MODEL",
 			"GET_MODEL",
 			{
 			{
@@ -183,7 +184,8 @@ export default {
 		async.waterfall(
 		async.waterfall(
 			[
 			[
 				next => {
 				next => {
-					playlistModel.find({ createdBy: session.userId }, next);
+					if (showNonModifiablePlaylists) playlistModel.find({ createdBy: session.userId }, next);
+					else playlistModel.find({ createdBy: session.userId, isUserModifiable: true }, next);
 				}
 				}
 			],
 			],
 			async (err, playlists) => {
 			async (err, playlists) => {

+ 1 - 1
frontend/src/components/modals/EditStation.vue

@@ -504,7 +504,7 @@ export default {
 		io.getSocket(socket => {
 		io.getSocket(socket => {
 			this.socket = socket;
 			this.socket = socket;
 
 
-			this.socket.emit("playlists.indexForUser", res => {
+			this.socket.emit("playlists.indexForUser", true, res => {
 				if (res.status === "success") this.playlists = res.data;
 				if (res.status === "success") this.playlists = res.data;
 			});
 			});
 
 

+ 8 - 4
frontend/src/pages/Profile.vue

@@ -246,10 +246,14 @@ export default {
 						this.isUser = true;
 						this.isUser = true;
 
 
 						if (this.user._id === this.userId) {
 						if (this.user._id === this.userId) {
-							this.socket.emit("playlists.indexForUser", res => {
-								if (res.status === "success")
-									this.playlists = res.data;
-							});
+							this.socket.emit(
+								"playlists.indexForUser",
+								true,
+								res => {
+									if (res.status === "success")
+										this.playlists = res.data;
+								}
+							);
 
 
 							this.socket.emit(
 							this.socket.emit(
 								"activities.getSet",
 								"activities.getSet",

+ 1 - 1
frontend/src/pages/Station/AddSongToQueue.vue

@@ -239,7 +239,7 @@ export default {
 	mounted() {
 	mounted() {
 		io.getSocket(socket => {
 		io.getSocket(socket => {
 			this.socket = socket;
 			this.socket = socket;
-			this.socket.emit("playlists.indexForUser", res => {
+			this.socket.emit("playlists.indexForUser", true, res => {
 				if (res.status === "success") this.playlists = res.data;
 				if (res.status === "success") this.playlists = res.data;
 			});
 			});
 		});
 		});

+ 2 - 2
frontend/src/pages/Station/components/AddToPlaylistDropdown.vue

@@ -31,7 +31,7 @@
 			</button>
 			</button>
 		</div>
 		</div>
 		<p class="nav-dropdown-items" id="no-playlists" v-else>
 		<p class="nav-dropdown-items" id="no-playlists" v-else>
-			You haven't created any playlists
+			You haven't created any playlists.
 		</p>
 		</p>
 	</div>
 	</div>
 </template>
 </template>
@@ -61,7 +61,7 @@ export default {
 		this.song = this.currentSong;
 		this.song = this.currentSong;
 		io.getSocket(socket => {
 		io.getSocket(socket => {
 			this.socket = socket;
 			this.socket = socket;
-			this.socket.emit("playlists.indexForUser", res => {
+			this.socket.emit("playlists.indexForUser", false, res => {
 				if (res.status === "success") {
 				if (res.status === "success") {
 					res.data.forEach(playlist => {
 					res.data.forEach(playlist => {
 						this.playlists[playlist._id] = playlist;
 						this.playlists[playlist._id] = playlist;

+ 1 - 1
frontend/src/pages/Station/components/Sidebar/MyPlaylists.vue

@@ -74,7 +74,7 @@ export default {
 			this.socket = socket;
 			this.socket = socket;
 
 
 			/** Get playlists for user */
 			/** Get playlists for user */
-			this.socket.emit("playlists.indexForUser", res => {
+			this.socket.emit("playlists.indexForUser", true, res => {
 				if (res.status === "success") this.playlists = res.data;
 				if (res.status === "success") this.playlists = res.data;
 			});
 			});