Browse Source

fix(Home): keyboard shortcut to toggle admin filter never got created if connection was too slow

Kristian Vos 2 years ago
parent
commit
c293c4bce7
1 changed files with 25 additions and 22 deletions
  1. 25 22
      frontend/src/pages/Home.vue

+ 25 - 22
frontend/src/pages/Home.vue

@@ -743,28 +743,6 @@ export default {
 		this.socket.on("event:user.orderOfFavoriteStations.updated", res => {
 			this.orderOfFavoriteStations = res.data.order;
 		});
-
-		if (this.isAdmin()) {
-			// ctrl + alt + f
-			keyboardShortcuts.registerShortcut("home.toggleAdminFilter", {
-				keyCode: 70,
-				ctrl: true,
-				alt: true,
-				handler: () => {
-					if (this.$route.query.adminFilter === undefined)
-						this.$router.push({
-							query: { ...this.$route.query, adminFilter: null }
-						});
-					else
-						this.$router.push({
-							query: {
-								...this.$route.query,
-								adminFilter: undefined
-							}
-						});
-				}
-			});
-		}
 	},
 	beforeUnmount() {
 		this.socket.dispatch("apis.leaveRoom", "home", () => {});
@@ -807,6 +785,31 @@ export default {
 			);
 
 			this.socket.dispatch("apis.joinRoom", "home");
+
+			if (this.isAdmin()) {
+				// ctrl + alt + f
+				keyboardShortcuts.registerShortcut("home.toggleAdminFilter", {
+					keyCode: 70,
+					ctrl: true,
+					alt: true,
+					handler: () => {
+						if (this.$route.query.adminFilter === undefined)
+							this.$router.push({
+								query: {
+									...this.$route.query,
+									adminFilter: null
+								}
+							});
+						else
+							this.$router.push({
+								query: {
+									...this.$route.query,
+									adminFilter: undefined
+								}
+							});
+					}
+				});
+			}
 		},
 		isOwner(station) {
 			return this.loggedIn && station.owner === this.userId;