Browse Source

fix(Station Skipping): homepage doesn't automatically update when a song changes

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 3 years ago
parent
commit
9fdaaeb5a6

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

@@ -1209,8 +1209,6 @@ export default {
 
 					if (youtubeIds.length === 0) next();
 
-					console.log(youtubeIds);
-
 					async.eachLimit(
 						youtubeIds,
 						1,

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

@@ -1470,11 +1470,7 @@ export default {
 
 		async.waterfall(
 			[
-				next => {
-					console.log(youtubeId);
-					songModel.findOne({ youtubeId }, next);
-				},
-
+				next => songModel.findOne({ youtubeId }, next),
 				(song, next) => {
 					if (!song) return next("No song found with that id.");
 					return next(null);

+ 12 - 21
backend/logic/stations.js

@@ -957,37 +957,28 @@ class _StationsModule extends CoreClass {
 									}
 								}
 							]
-						})
-							.then()
-							.catch();
+						});
 
-						if (station.privacy === "public") {
+						if (station.privacy === "public")
 							WSModule.runJob("EMIT_TO_ROOM", {
 								room: "home",
 								args: [
 									"event:station.nextSong",
 									{ data: { stationId: station._id, song: station.currentSong } }
 								]
-							})
-								.then()
-								.catch();
-						} else {
+							});
+						else {
 							const sockets = await WSModule.runJob("GET_SOCKETS_FOR_ROOM", { room: "home" }, this);
 
 							sockets.forEach(async socketId => {
-								const socket = await WSModule.runJob("SOCKET_FROM_SOCKET_ID", { socketId }, this);
+								const socket = await WSModule.runJob("SOCKET_FROM_SOCKET_ID", { socketId });
 								const { session } = socket;
 
 								if (session.sessionId) {
-									CacheModule.runJob(
-										"HGET",
-										{ table: "sessions", key: session.sessionId },
-										this
-										// eslint-disable-next-line no-loop-func
-									).then(session => {
-										if (session) {
-											DBModule.runJob("GET_MODEL", { modelName: "user" }, this).then(
-												userModel => {
+									CacheModule.runJob("HGET", { table: "sessions", key: session.sessionId }).then(
+										session => {
+											if (session) {
+												DBModule.runJob("GET_MODEL", { modelName: "user" }).then(userModel => {
 													userModel.findOne(
 														{
 															_id: session.userId
@@ -1014,10 +1005,10 @@ class _StationsModule extends CoreClass {
 															}
 														}
 													);
-												}
-											);
+												});
+											}
 										}
-									});
+									);
 								}
 							});
 						}

+ 2 - 1
frontend/src/pages/Home.vue

@@ -615,6 +615,7 @@ export default {
 		});
 
 		this.socket.on("event:station.nextSong", res => {
+			console.log("NEXT SONG!");
 			const station = this.stations.find(
 				station => station._id === res.data.stationId
 			);
@@ -706,7 +707,7 @@ export default {
 				}
 			});
 
-			this.socket.dispatch("apis.joinRoom", "home", () => {});
+			this.socket.dispatch("apis.joinRoom", "home");
 		},
 		isOwner(station) {
 			return station.owner === this.userId;