Merge pull request #1018 from swordbeta/sort_channel_list

Improve channels list.
This commit is contained in:
Jérémie Astori 2017-04-20 01:40:14 -04:00 committed by GitHub
commit 4de632ba3c
3 changed files with 14 additions and 3 deletions

View file

@ -1017,6 +1017,10 @@ kbd {
border-bottom: #eee 1px solid;
}
#chat table.channel-list .channel {
width: 80px;
}
#chat table.channel-list .channel,
#chat table.channel-list .topic {
text-align: left;
@ -1024,6 +1028,7 @@ kbd {
#chat table.channel-list .users {
text-align: center;
width: 50px;
}
#chat table.channel-list td.channel .inline-channel {

View file

@ -427,6 +427,10 @@ $(function() {
var target = "#chan-" + data.chan;
var container = chat.find(target + " .messages");
if (data.msg.type === "channel_list") {
$(container).empty();
}
// Check if date changed
var prevMsg = $(container.find(".msg")).last();
var prevMsgTime = new Date(prevMsg.attr("data-time"));
@ -1086,7 +1090,7 @@ $(function() {
}
var chanChat = chan.find(".chat");
if (chanChat.length > 0) {
if (chanChat.length > 0 && chan.data("type") !== "special") {
chanChat.sticky();
}

View file

@ -5,7 +5,7 @@ var Msg = require("../../models/msg");
module.exports = function(irc, network) {
var client = this;
var MAX_CHANS = 1000;
var MAX_CHANS = 500;
irc.on("channel list start", function() {
network.chanCache = [];
@ -23,7 +23,9 @@ module.exports = function(irc, network) {
irc.on("channel list end", function() {
updateListStatus(new Msg({
type: "channel_list",
channels: network.chanCache.slice(0, MAX_CHANS)
channels: network.chanCache.sort(function(a, b) {
return b.num_users - a.num_users;
}).slice(0, MAX_CHANS)
}));
if (network.chanCache.length > MAX_CHANS) {