Merge pull request #489 from thelounge/astorije/fix-parting

Send user to lobby of deleted chan when parting from active chan
This commit is contained in:
Maxime Poulin 2016-07-15 03:00:31 +00:00 committed by GitHub
commit ebab910e00

View File

@ -393,29 +393,15 @@ $(function() {
}); });
socket.on("part", function(data) { socket.on("part", function(data) {
var id = data.chan; var chanMenuItem = sidebar.find(".chan[data-id='" + data.chan + "']");
sidebar.find(".chan[data-id='" + id + "']").remove();
$("#chan-" + id).remove();
var next = null; // When parting from the active channel/query, jump to the network's lobby
var highest = -1; if (chanMenuItem.hasClass("active")) {
chat.find(".chan").each(function() { chanMenuItem.parent(".network").find(".lobby").click();
var self = $(this);
var z = parseInt(self.css("z-index"));
if (z > highest) {
highest = z;
next = self;
} }
});
if (next !== null) { chanMenuItem.remove();
id = next.data("id"); $("#chan-" + data.chan).remove();
sidebar.find("[data-id=" + id + "]").click();
} else {
sidebar.find(".chan")
.eq(0)
.click();
}
}); });
socket.on("quit", function(data) { socket.on("quit", function(data) {