From c9d4513b269c051b6df8d4d6c5ebde6b05f7f052 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Mon, 11 Jul 2016 01:20:23 -0400 Subject: [PATCH] Send user to lobby of deleted chan when parting from active chan Instead of always sending them back to the very first lobby on the app. This fixes a bug introduced in recent layout change but does not bring previous behavior back: When closing active channel, user gets sent to lobby instead of previously visited channel. --- client/js/lounge.js | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/client/js/lounge.js b/client/js/lounge.js index 3c767ad4..b5de2860 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -393,29 +393,15 @@ $(function() { }); socket.on("part", function(data) { - var id = data.chan; - sidebar.find(".chan[data-id='" + id + "']").remove(); - $("#chan-" + id).remove(); + var chanMenuItem = sidebar.find(".chan[data-id='" + data.chan + "']"); - var next = null; - var highest = -1; - chat.find(".chan").each(function() { - var self = $(this); - var z = parseInt(self.css("z-index")); - if (z > highest) { - highest = z; - next = self; - } - }); - - if (next !== null) { - id = next.data("id"); - sidebar.find("[data-id=" + id + "]").click(); - } else { - sidebar.find(".chan") - .eq(0) - .click(); + // When parting from the active channel/query, jump to the network's lobby + if (chanMenuItem.hasClass("active")) { + chanMenuItem.parent(".network").find(".lobby").click(); } + + chanMenuItem.remove(); + $("#chan-" + data.chan).remove(); }); socket.on("quit", function(data) {