filter absent users from the userlist

pull/1/head
ansuz 8 years ago
parent ac3ddbab70
commit c858b247c1

@ -112,9 +112,18 @@ define([
editor.setOption('readOnly', !bool); editor.setOption('readOnly', !bool);
}; };
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 toolbarList; // List of users still connected to the channel (server IDs)
var addToUserList = function(data) { 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]; } for (var attrname in data) { userList[attrname] = data[attrname]; }
if(toolbarList && typeof toolbarList.onChange === "function") { if(toolbarList && typeof toolbarList.onChange === "function") {
toolbarList.onChange(userList); toolbarList.onChange(userList);
@ -502,6 +511,7 @@ define([
var onReady = config.onReady = function (info) { var onReady = config.onReady = function (info) {
var realtime = module.realtime = info.realtime; var realtime = module.realtime = info.realtime;
module.users = info.userList.users;
module.patchText = TextPatcher.create({ module.patchText = TextPatcher.create({
realtime: realtime, realtime: realtime,
//logging: true //logging: true

@ -149,9 +149,18 @@ define([
editor.setOption('readOnly', !bool); editor.setOption('readOnly', !bool);
}; };
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 toolbarList; // List of users still connected to the channel (server IDs)
var addToUserList = function(data) { 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]; } for (var attrname in data) { userList[attrname] = data[attrname]; }
if(toolbarList && typeof toolbarList.onChange === "function") { if(toolbarList && typeof toolbarList.onChange === "function") {
toolbarList.onChange(userList); toolbarList.onChange(userList);
@ -592,6 +601,7 @@ define([
var onReady = config.onReady = function (info) { var onReady = config.onReady = function (info) {
var realtime = module.realtime = info.realtime; var realtime = module.realtime = info.realtime;
module.users = info.userList.users;
module.patchText = TextPatcher.create({ module.patchText = TextPatcher.create({
realtime: realtime, realtime: realtime,
//logging: true //logging: true

Loading…
Cancel
Save