From c4a3108dc08d35854b47e5b731d93cd274626c54 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Wed, 27 Feb 2019 20:15:58 +0200 Subject: [PATCH] Move activeWindow to vuex. --- client/components/App.vue | 2 +- client/js/lounge.js | 4 ++-- client/js/socket-events/auth.js | 4 ++-- client/js/store.js | 4 ++++ client/js/vue.js | 1 - 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/client/components/App.vue b/client/components/App.vue index 12637d20..b45b5b81 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -12,7 +12,7 @@ :network="activeChannel.network" :channel="activeChannel.channel" /> diff --git a/client/js/lounge.js b/client/js/lounge.js index ea7e58cf..a55b98ab 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -128,7 +128,7 @@ window.vueMounted = () => { } if (channel) { - vueApp.activeWindow = null; + vueApp.$store.commit("activeWindow", null); vueApp.activeChannel = channel; if (channel) { @@ -143,7 +143,7 @@ window.vueMounted = () => { } } else { vueApp.activeChannel = null; - vueApp.activeWindow = target; + vueApp.$store.commit("activeWindow", target); } utils.synchronizeNotifiedState(); diff --git a/client/js/socket-events/auth.js b/client/js/socket-events/auth.js index 526881b5..b01cf6e3 100644 --- a/client/js/socket-events/auth.js +++ b/client/js/socket-events/auth.js @@ -20,7 +20,7 @@ socket.on("auth", function(data) { if (data.serverHash > -1) { utils.serverHash = data.serverHash; - vueApp.activeWindow = "SignIn"; + vueApp.$store.commit("activeWindow", "SignIn"); } else { getActiveWindowComponent().inFlight = false; } @@ -29,7 +29,7 @@ socket.on("auth", function(data) { const user = storage.get("user"); if (!data.success) { - if (vueApp.activeWindow !== "SignIn") { + if (vueApp.$store.state.activeWindow !== "SignIn") { socket.disconnect(); vueApp.$store.commit("isConnected", false); vueApp.currentUserVisibleError = "Authentication failed, reloading…"; diff --git a/client/js/store.js b/client/js/store.js index 407282fe..5003024a 100644 --- a/client/js/store.js +++ b/client/js/store.js @@ -7,6 +7,7 @@ export default new Vuex.Store({ state: { isConnected: false, isNotified: false, + activeWindow: null, }, mutations: { isConnected(state, payload) { @@ -15,5 +16,8 @@ export default new Vuex.Store({ isNotified(state, payload) { state.isNotified = payload; }, + activeWindow(state, payload) { + state.activeWindow = payload; + }, } }); diff --git a/client/js/vue.js b/client/js/vue.js index 43422e84..2bec7e5e 100644 --- a/client/js/vue.js +++ b/client/js/vue.js @@ -16,7 +16,6 @@ Vue.filter("roundBadgeNumber", roundBadgeNumber); const vueApp = new Vue({ el: "#viewport", data: { - activeWindow: null, activeChannel: null, appName: document.title, currentUserVisibleError: null,