Switch channels on quit only if current network is being quit

This commit is contained in:
Pavel Djundik 2019-11-11 14:19:03 +02:00
parent d5ebdc943c
commit 2044bc88dd
3 changed files with 16 additions and 23 deletions

View File

@ -1,9 +1,8 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const storage = require("../localStorage"); const storage = require("../localStorage");
const {getActiveWindowComponent} = require("../vue"); const {vueApp, getActiveWindowComponent} = require("../vue");
const store = require("../store").default; const store = require("../store").default;
let lastServerHash = null; let lastServerHash = null;
@ -79,11 +78,7 @@ function showSignIn() {
window.g_TheLoungeRemoveLoading(); window.g_TheLoungeRemoveLoading();
} }
$("#footer") vueApp.$router.push("/sign-in");
.find(".sign-in")
.trigger("click", {
pushState: false,
});
} }
function reloadPage(message) { function reloadPage(message) {

View File

@ -1,6 +1,5 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const webpush = require("../webpush"); const webpush = require("../webpush");
const storage = require("../localStorage"); 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 // For example, it can be unset if you first open the page after server start
vueApp.switchToChannel(store.state.networks[0].channels[0]); vueApp.switchToChannel(store.state.networks[0].channels[0]);
} else { } else {
// TODO: Use vue router vueApp.$router.push("/connect");
$("#footer .connect").trigger("click");
} }
} }
} }

View File

@ -1,24 +1,24 @@
"use strict"; "use strict";
const $ = require("jquery");
const socket = require("../socket"); const socket = require("../socket");
const sidebar = $("#sidebar");
const {vueApp} = require("../vue"); const {vueApp} = require("../vue");
const store = require("../store").default; const store = require("../store").default;
socket.on("quit", function(data) { 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); store.commit("removeNetwork", data.network);
vueApp.$nextTick(() => { if (!isCurrentNetworkBeingRemoved) {
const chan = sidebar.find(".chan"); return;
}
if (chan.length === 0) { if (store.state.networks.length > 0) {
// Open the connect window vueApp.switchToChannel(store.state.networks[0].channels[0]);
$("#footer .connect").trigger("click", { } else {
pushState: false, vueApp.$router.push("/connect");
}); }
} else {
chan.eq(0).trigger("click");
}
});
}); });