Commit 0b5e40bc authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Set user-status-raisehand when adding user.

Commit 993d66 addes support for displaying raised hands, but it
failed to take into account the possibility that the hand is already
raised when the user is first added.
parent c1eb8a9c
......@@ -1961,26 +1961,27 @@ function stringCompare(a, b) {
/**
* @param {string} id
* @param {string} name
* @param {user} userinfo
*/
function addUser(id, name) {
if(!name)
name = null;
function addUser(id, userinfo) {
let div = document.getElementById('users');
let user = document.createElement('div');
user.id = 'user-' + id;
user.classList.add("user-p");
user.textContent = name ? name : '(anon)';
user.textContent = userinfo.username ? userinfo.username : '(anon)';
if (userinfo.status.raisehand)
user.classList.add('user-status-raisehand');
else
user.classList.remove('user-status-raisehand');
if(name) {
if(userinfo.username) {
let us = div.children;
for(let i = 0; i < us.length; i++) {
let child = us[i];
let childuser =
serverConnection.users[child.id.slice('user-'.length)] || null;
let childname = (childuser && childuser.username) || null;
if(!childname || stringCompare(childname, name) > 0) {
if(!childname || stringCompare(childname, userinfo.username) > 0) {
div.insertBefore(user, child);
return;
}
......@@ -2022,7 +2023,7 @@ function delUser(id) {
function gotUser(id, kind) {
switch(kind) {
case 'add':
addUser(id, serverConnection.users[id].username);
addUser(id, serverConnection.users[id]);
if(Object.keys(serverConnection.users).length == 3)
reconsiderSendParameters();
break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment