Replace getActiveWindowComponent with an event

This commit is contained in:
Pavel Djundik 2019-11-11 15:48:47 +02:00
parent 3a6b075745
commit 5a0f1c1f4e
3 changed files with 15 additions and 11 deletions

View file

@ -71,7 +71,17 @@ export default {
errorShown: false, errorShown: false,
}; };
}, },
mounted() {
this.$root.$on("auth:failed", this.onAuthFailed);
},
beforeDestroy() {
this.$root.$off("auth:failed", this.onAuthFailed);
},
methods: { methods: {
onAuthFailed() {
this.inFlight = false;
this.errorShown = true;
},
onSubmit(event) { onSubmit(event) {
event.preventDefault(); event.preventDefault();

View file

@ -2,7 +2,7 @@
const socket = require("../socket"); const socket = require("../socket");
const storage = require("../localStorage"); const storage = require("../localStorage");
const {vueApp, getActiveWindowComponent} = require("../vue"); const {vueApp} = require("../vue");
const store = require("../store").default; const store = require("../store").default;
let lastServerHash = null; let lastServerHash = null;
@ -18,12 +18,9 @@ socket.on("auth:failed", function() {
return reloadPage("Authentication failed, reloading…"); return reloadPage("Authentication failed, reloading…");
} }
// TODO: This will most likely fail getActiveWindowComponent
showSignIn(); showSignIn();
// TODO: getActiveWindowComponent is the SignIn component, find a better way to set this vueApp.$emit("auth:failed");
getActiveWindowComponent().errorShown = true;
getActiveWindowComponent().inFlight = false;
}); });
socket.on("auth:start", function(serverHash) { socket.on("auth:start", function(serverHash) {
@ -78,7 +75,9 @@ function showSignIn() {
window.g_TheLoungeRemoveLoading(); window.g_TheLoungeRemoveLoading();
} }
vueApp.$router.push("/sign-in"); if (vueApp.$route.name !== "SignIn") {
vueApp.$router.push("/sign-in");
}
} }
function reloadPage(message) { function reloadPage(message) {

View file

@ -120,12 +120,7 @@ function initChannel(channel) {
} }
} }
function getActiveWindowComponent() {
return vueApp.$refs.app.$refs.window;
}
module.exports = { module.exports = {
vueApp, vueApp,
initChannel, initChannel,
getActiveWindowComponent,
}; };