Lazily load user list

This commit is contained in:
Pavel Djundik 2017-07-10 13:56:58 +03:00
parent 7af573fd96
commit d06c279f02
2 changed files with 9 additions and 2 deletions

View File

@ -144,7 +144,7 @@ function renderChannelMessages(data) {
function renderChannelUsers(data) {
const users = chat.find("#chan-" + data.id).find(".users");
const nicks = data.users
.concat()
.concat() // Make a copy of the user list, sort is applied in-place
.sort((a, b) => b.lastMessage - a.lastMessage)
.map((a) => a.nick);
@ -179,7 +179,13 @@ function renderNetworks(data) {
channels: channels
})
);
channels.forEach(renderChannel);
channels.forEach((channel) => {
renderChannel(channel);
if (channel.type === "channel") {
chat.find("#chan-" + channel.id).data("needsNamesRefresh", true);
}
});
utils.confirmExit();
sorting();

View File

@ -108,6 +108,7 @@ Chan.prototype.getMode = function(name) {
Chan.prototype.toJSON = function() {
var clone = _.clone(this);
clone.users = []; // Do not send user list, the client will explicitly request it when needed
clone.messages = clone.messages.slice(-100);
return clone;
};