From 0b5e40bc7f67182fa1f0bf49398d5325df4ff190 Mon Sep 17 00:00:00 2001 From: Juliusz Chroboczek Date: Fri, 28 Jan 2022 22:13:14 +0100 Subject: [PATCH] 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. --- static/galene.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/static/galene.js b/static/galene.js index 6cea502..192cee4 100644 --- a/static/galene.js +++ b/static/galene.js @@ -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;