From 46c5f643697c0ac50c5b7a7ba63a194852bb365b Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 19 Oct 2016 12:30:25 +0200 Subject: [PATCH] remove absent users from the userlist --- www/pad/main.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/www/pad/main.js b/www/pad/main.js index aa305c715..78b49fc8f 100644 --- a/www/pad/main.js +++ b/www/pad/main.js @@ -250,9 +250,16 @@ define([ }; var initializing = true; - var userList = {}; // List of pretty name of all users (mapped with their server ID) + var userList = module.userList = {}; // List of pretty name of all users (mapped with their server ID) var toolbarList; // List of users still connected to the channel (server IDs) var addToUserList = function(data) { + var users = module.users; + if (users && users.length) { + for (var userKey in userList) { + if (users.indexOf(userKey) === -1) { delete userList[userKey]; } + } + } + for (var attrname in data) { userList[attrname] = data[attrname]; } if(toolbarList && typeof toolbarList.onChange === "function") { toolbarList.onChange(userList); @@ -603,6 +610,7 @@ define([ //logging: true, }); + module.users = info.userList.users; module.realtime = info.realtime; var shjson = info.realtime.getUserDoc();