diff --git a/client/js/socket-events/auth.js b/client/js/socket-events/auth.js index 632d828b..d7b9d362 100644 --- a/client/js/socket-events/auth.js +++ b/client/js/socket-events/auth.js @@ -1,9 +1,8 @@ "use strict"; -const $ = require("jquery"); const socket = require("../socket"); const storage = require("../localStorage"); -const {getActiveWindowComponent} = require("../vue"); +const {vueApp, getActiveWindowComponent} = require("../vue"); const store = require("../store").default; let lastServerHash = null; @@ -79,11 +78,7 @@ function showSignIn() { window.g_TheLoungeRemoveLoading(); } - $("#footer") - .find(".sign-in") - .trigger("click", { - pushState: false, - }); + vueApp.$router.push("/sign-in"); } function reloadPage(message) { diff --git a/client/js/socket-events/init.js b/client/js/socket-events/init.js index b9910701..5bc226c1 100644 --- a/client/js/socket-events/init.js +++ b/client/js/socket-events/init.js @@ -1,6 +1,5 @@ "use strict"; -const $ = require("jquery"); const socket = require("../socket"); const webpush = require("../webpush"); const storage = require("../localStorage"); @@ -56,8 +55,7 @@ socket.on("init", function(data) { // For example, it can be unset if you first open the page after server start vueApp.switchToChannel(store.state.networks[0].channels[0]); } else { - // TODO: Use vue router - $("#footer .connect").trigger("click"); + vueApp.$router.push("/connect"); } } } diff --git a/client/js/socket-events/quit.js b/client/js/socket-events/quit.js index 8107bdce..8b6add37 100644 --- a/client/js/socket-events/quit.js +++ b/client/js/socket-events/quit.js @@ -1,24 +1,24 @@ "use strict"; -const $ = require("jquery"); const socket = require("../socket"); -const sidebar = $("#sidebar"); const {vueApp} = require("../vue"); const store = require("../store").default; socket.on("quit", function(data) { + // If we're in a channel, and it's on the network that is being removed, + // then open another channel window + const isCurrentNetworkBeingRemoved = + store.state.activeChannel && store.state.activeChannel.network.uuid === data.network; + store.commit("removeNetwork", data.network); - vueApp.$nextTick(() => { - const chan = sidebar.find(".chan"); + if (!isCurrentNetworkBeingRemoved) { + return; + } - if (chan.length === 0) { - // Open the connect window - $("#footer .connect").trigger("click", { - pushState: false, - }); - } else { - chan.eq(0).trigger("click"); - } - }); + if (store.state.networks.length > 0) { + vueApp.switchToChannel(store.state.networks[0].channels[0]); + } else { + vueApp.$router.push("/connect"); + } });