From d06c279f026a45211670432f50cf29b848e874e6 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Mon, 10 Jul 2017 13:56:58 +0300 Subject: [PATCH] Lazily load user list --- client/js/render.js | 10 ++++++++-- src/models/chan.js | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/client/js/render.js b/client/js/render.js index 2cebfdb6..bfb653d2 100644 --- a/client/js/render.js +++ b/client/js/render.js @@ -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(); diff --git a/src/models/chan.js b/src/models/chan.js index 6ca5eb54..af4607a8 100644 --- a/src/models/chan.js +++ b/src/models/chan.js @@ -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; };