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"
:channel="activeChannel.channel" />
<component
:is="activeWindow"
:is="$store.state.activeWindow"
ref="window" />
</article>
</div>

View File

@ -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();

View File

@ -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…";

View File

@ -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;
},
}
});

View File

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