Merge pull request #2733 from thelounge/xpaw/sort-lobby-enforce

Enforce lobby to be the 0th channel when sorting
This commit is contained in:
Jérémie Astori 2018-09-01 01:13:04 -04:00 committed by GitHub
commit aabe0824a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -452,7 +452,17 @@ Client.prototype.sort = function(data) {
return;
}
network.channels.sort((a, b) => order.indexOf(a.id) - order.indexOf(b.id));
network.channels.sort((a, b) => {
// Always sort lobby to the top regardless of what the client has sent
// Because there's a lot of code that presumes channels[0] is the lobby
if (a.type === Chan.Type.LOBBY) {
return -1;
} else if (b.type === Chan.Type.LOBBY) {
return 1;
}
return order.indexOf(a.id) - order.indexOf(b.id);
});
// Sync order to connected clients
this.emit("sync_sort", {