Browse Source

Added confirmation to deselect blacklisted playlist

Owen Diffey 3 years ago
parent
commit
49436e1fb0

+ 2 - 2
backend/logic/actions/apis.js

@@ -144,7 +144,7 @@ export default {
 	 * @param {string} room - the room to leave
 	 * @param {Function} cb - callback
 	 */
-	 leaveRoom(session, room, cb) {
+	leaveRoom(session, room, cb) {
 		if (room === "home" || room.startsWith("profile.") || room.startsWith("manage-station.")) {
 			WSModule.runJob("SOCKET_LEAVE_ROOM", {
 				socketId: session.socketId,
@@ -195,7 +195,7 @@ export default {
 	 * @param {object} session - user session
 	 * @param {Function} cb - callback
 	 */
-	 leaveRooms(session, cb) {
+	leaveRooms(session, cb) {
 		WSModule.runJob("SOCKET_LEAVE_ROOMS", { socketId: session.socketId });
 
 		cb({ status: "success", message: "Successfully left all rooms." });

+ 15 - 13
backend/logic/actions/utils.js

@@ -82,19 +82,21 @@ export default {
 	}),
 
 	getRooms(session, cb) {
-		WSModule.runJob("GET_ROOMS_FOR_SOCKET", { socketId: session.socketId }).then(response => {
-			this.log("SUCCESS", "GET_ROOMS", `User ${session.userId} has successfully got the module info.`);
-			cb({
-				status: "success",
-				message: "Successfully got rooms.",
-				data: {
-					rooms: response
-				}
+		WSModule.runJob("GET_ROOMS_FOR_SOCKET", { socketId: session.socketId })
+			.then(response => {
+				this.log("SUCCESS", "GET_ROOMS", `User ${session.userId} has successfully got the module info.`);
+				cb({
+					status: "success",
+					message: "Successfully got rooms.",
+					data: {
+						rooms: response
+					}
+				});
+			})
+			.catch(async err => {
+				err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
+				this.log("ERROR", "GET_ROOMS", `Failed to get rooms. '${err}'`);
+				cb({ status: "error", message: err });
 			});
-		}).catch(async err => {
-			err = await UtilsModule.runJob("GET_ERROR", { error: err }, this);
-			this.log("ERROR", "GET_ROOMS", `Failed to get rooms. '${err}'`);
-			cb({ status: "error", message: err });
-		});
 	}
 };

+ 5 - 2
backend/logic/ws.js

@@ -271,10 +271,13 @@ class _WSModule extends CoreClass {
 	 * @param {string} payload.room - the room
 	 * @returns {Promise} - returns promise (reject, resolve)
 	 */
-	 async SOCKET_LEAVE_ROOM(payload) {
+	async SOCKET_LEAVE_ROOM(payload) {
 		return new Promise(resolve => {
 			// filter out rooms that the user is in
-			if (WSModule.rooms[payload.room]) WSModule.rooms[payload.room] = WSModule.rooms[payload.room].filter(participant => participant !== payload.socketId);
+			if (WSModule.rooms[payload.room])
+				WSModule.rooms[payload.room] = WSModule.rooms[payload.room].filter(
+					participant => participant !== payload.socketId
+				);
 
 			return resolve();
 		});

+ 11 - 8
frontend/src/components/modals/ManageStation/Tabs/Blacklist.vue

@@ -29,14 +29,15 @@
 						:key="'key-' + index"
 					>
 						<div class="icons-group" slot="actions">
-							<i
-								@click="deselectPlaylist(playlist._id)"
-								class="material-icons stop-icon"
-								content="Stop blacklisting songs from this playlist
+							<confirm @confirm="deselectPlaylist(playlist._id)">
+								<i
+									class="material-icons stop-icon"
+									content="Stop blacklisting songs from this playlist
 							"
-								v-tippy
-								>stop</i
-							>
+									v-tippy
+									>stop</i
+								>
+							</confirm>
 							<i
 								v-if="playlist.createdBy === userId"
 								@click="showPlaylist(playlist._id)"
@@ -71,10 +72,12 @@ import { mapActions, mapState, mapGetters } from "vuex";
 
 import Toast from "toasters";
 import PlaylistItem from "@/components/PlaylistItem.vue";
+import Confirm from "@/components/Confirm.vue";
 
 export default {
 	components: {
-		PlaylistItem
+		PlaylistItem,
+		Confirm
 	},
 	data() {
 		return {

+ 5 - 1
frontend/src/components/modals/ManageStation/Tabs/Playlists.vue

@@ -192,7 +192,7 @@
 					</playlist-item>
 					<button
 						v-if="resultsLeftCount > 0"
-						class="button is-primary"
+						class="button is-primary load-more-button"
 						@click="searchForPlaylists(search.page + 1)"
 					>
 						Load {{ nextPageResultsCount }} more results
@@ -612,6 +612,10 @@ export default {
 			.item.item-draggable:not(:last-of-type) {
 				margin-bottom: 10px;
 			}
+			.load-more-button {
+				width: 100%;
+				margin-top: 10px;
+			}
 		}
 	}
 }