Browse Source

fix(Station page): loading station from home page didn't always get favourite boolean

Signed-off-by: Jonathan <theflametrooper@gmail.com>
Jonathan 4 years ago
parent
commit
685434a289
1 changed files with 11 additions and 7 deletions
  1. 11 7
      frontend/src/pages/Station/index.vue

+ 11 - 7
frontend/src/pages/Station/index.vue

@@ -1243,6 +1243,7 @@ export default {
 					this.updateUserCount(res.data.userCount);
 					this.updateUsers(res.data.users);
 					this.pausedAt = res.data.pausedAt;
+
 					if (res.data.currentSong) {
 						this.updateNoSong(false);
 						this.youtubeReady();
@@ -1270,6 +1271,16 @@ export default {
 						});
 					}
 
+					/** Check if station is favourited */
+					this.socket.emit("users.getFavoriteStations", data => {
+						if (
+							data.status === "success" &&
+							data.favoriteStations.indexOf(this.station._id) !==
+								-1
+						)
+							this.favoriteStation = true;
+					});
+
 					if (this.isOwnerOrAdmin()) {
 						keyboardShortcuts.registerShortcut(
 							"station.pauseResume",
@@ -1392,13 +1403,6 @@ export default {
 					this.exists = false;
 				}
 			});
-			this.socket.emit("users.getFavoriteStations", data => {
-				if (
-					data.status === "success" &&
-					data.favoriteStations.indexOf(this.station._id) !== -1
-				)
-					this.favoriteStation = true;
-			});
 		},
 		addfavoriteStation(event) {
 			event.preventDefault();