Browse Source

Merge branch 'polishing' of github.com:Musare/MusareNode into polishing

Jonathan 3 years ago
parent
commit
1bd7d2c555

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

@@ -123,7 +123,12 @@ export default {
 	 * @param {Function} cb - callback
 	 */
 	joinRoom(session, page, cb) {
-		if (page === "home" || page.startsWith("profile.") || page.startsWith("manage-station.")) {
+		if (
+			page === "home" ||
+			page.startsWith("profile.") ||
+			page.startsWith("manage-station.") ||
+			page.startsWith("edit-song.")
+		) {
 			WSModule.runJob("SOCKET_JOIN_ROOM", {
 				socketId: session.socketId,
 				room: page
@@ -145,7 +150,12 @@ export default {
 	 * @param {Function} cb - callback
 	 */
 	leaveRoom(session, room, cb) {
-		if (room === "home" || room.startsWith("profile.") || room.startsWith("manage-station.")) {
+		if (
+			room === "home" ||
+			room.startsWith("profile.") ||
+			room.startsWith("manage-station.") ||
+			room.startsWith("edit-song.")
+		) {
 			WSModule.runJob("SOCKET_LEAVE_ROOM", {
 				socketId: session.socketId,
 				room

+ 15 - 0
backend/logic/actions/songs.js

@@ -25,6 +25,11 @@ CacheModule.runJob("SUB", {
 				room: "admin.unverifiedSongs",
 				args: ["event:admin.unverifiedSong.added", { data: { song } }]
 			});
+
+			WSModule.runJob("EMIT_TO_ROOM", {
+				room: `edit-song.${songId}`,
+				args: ["event:admin.unverifiedSong.added", { data: { song } }]
+			});
 		});
 	}
 });
@@ -64,6 +69,11 @@ CacheModule.runJob("SUB", {
 				room: "admin.songs",
 				args: ["event:admin.verifiedSong.added", { data: { song } }]
 			});
+
+			WSModule.runJob("EMIT_TO_ROOM", {
+				room: `edit-song.${songId}`,
+				args: ["event:admin.verifiedSong.added", { data: { song } }]
+			});
 		});
 	}
 });
@@ -102,6 +112,11 @@ CacheModule.runJob("SUB", {
 				room: "admin.hiddenSongs",
 				args: ["event:admin.hiddenSong.added", { data: { song } }]
 			});
+
+			WSModule.runJob("EMIT_TO_ROOM", {
+				room: `edit-song.${songId}`,
+				args: ["event:admin.hiddenSong.added", { data: { song } }]
+			});
 		});
 	}
 });

+ 11 - 0
frontend/src/components/modals/EditSong.vue

@@ -674,6 +674,11 @@ export default {
 
 				this.songDataLoaded = true;
 
+				this.socket.dispatch(
+					"apis.joinRoom",
+					`edit-song.${this.song._id}`
+				);
+
 				// this.edit(res.data.song);
 
 				this.discogsQuery = this.song.title;
@@ -971,6 +976,12 @@ export default {
 		clearInterval(this.interval);
 		clearInterval(this.activityWatchVideoDataInterval);
 
+		this.socket.dispatch(
+			"apis.leaveRoom",
+			`edit-song.${this.song._id}`,
+			() => {}
+		);
+
 		const shortcutNames = [
 			"editSong.pauseResume",
 			"editSong.stopVideo",