Skip to content

Commit

Permalink
Merge pull request thelounge#489 from thelounge/astorije/fix-parting
Browse files Browse the repository at this point in the history
Send user to lobby of deleted chan when parting from active chan
  • Loading branch information
maxpoulin64 committed Jul 15, 2016
2 parents 7efbf14 + b016030 commit 32af323
Showing 1 changed file with 7 additions and 21 deletions.
28 changes: 7 additions & 21 deletions client/js/lounge.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 32af323

Please sign in to comment.