Move activeWindow to vuex.

This commit is contained in:
Richard Lewis 2019-02-27 20:15:58 +02:00 committed by Pavel Djundik
parent 0da059118d
commit c4a3108dc0
5 changed files with 9 additions and 6 deletions

View file

@ -12,7 +12,7 @@
:network="activeChannel.network" :network="activeChannel.network"
:channel="activeChannel.channel" /> :channel="activeChannel.channel" />
<component <component
:is="activeWindow" :is="$store.state.activeWindow"
ref="window" /> ref="window" />
</article> </article>
</div> </div>

View file

@ -128,7 +128,7 @@ window.vueMounted = () => {
} }
if (channel) { if (channel) {
vueApp.activeWindow = null; vueApp.$store.commit("activeWindow", null);
vueApp.activeChannel = channel; vueApp.activeChannel = channel;
if (channel) { if (channel) {
@ -143,7 +143,7 @@ window.vueMounted = () => {
} }
} else { } else {
vueApp.activeChannel = null; vueApp.activeChannel = null;
vueApp.activeWindow = target; vueApp.$store.commit("activeWindow", target);
} }
utils.synchronizeNotifiedState(); utils.synchronizeNotifiedState();

View file

@ -20,7 +20,7 @@ socket.on("auth", function(data) {
if (data.serverHash > -1) { if (data.serverHash > -1) {
utils.serverHash = data.serverHash; utils.serverHash = data.serverHash;
vueApp.activeWindow = "SignIn"; vueApp.$store.commit("activeWindow", "SignIn");
} else { } else {
getActiveWindowComponent().inFlight = false; getActiveWindowComponent().inFlight = false;
} }
@ -29,7 +29,7 @@ socket.on("auth", function(data) {
const user = storage.get("user"); const user = storage.get("user");
if (!data.success) { if (!data.success) {
if (vueApp.activeWindow !== "SignIn") { if (vueApp.$store.state.activeWindow !== "SignIn") {
socket.disconnect(); socket.disconnect();
vueApp.$store.commit("isConnected", false); vueApp.$store.commit("isConnected", false);
vueApp.currentUserVisibleError = "Authentication failed, reloading…"; vueApp.currentUserVisibleError = "Authentication failed, reloading…";

View file

@ -7,6 +7,7 @@ export default new Vuex.Store({
state: { state: {
isConnected: false, isConnected: false,
isNotified: false, isNotified: false,
activeWindow: null,
}, },
mutations: { mutations: {
isConnected(state, payload) { isConnected(state, payload) {
@ -15,5 +16,8 @@ export default new Vuex.Store({
isNotified(state, payload) { isNotified(state, payload) {
state.isNotified = payload; state.isNotified = payload;
}, },
activeWindow(state, payload) {
state.activeWindow = payload;
},
} }
}); });

View file

@ -16,7 +16,6 @@ Vue.filter("roundBadgeNumber", roundBadgeNumber);
const vueApp = new Vue({ const vueApp = new Vue({
el: "#viewport", el: "#viewport",
data: { data: {
activeWindow: null,
activeChannel: null, activeChannel: null,
appName: document.title, appName: document.title,
currentUserVisibleError: null, currentUserVisibleError: null,