1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-23 00:55:58 +01:00

Keep self at top of user list.

This commit is contained in:
Juliusz Chroboczek 2022-02-16 20:33:59 +01:00
parent d2dff184d1
commit 968390942c

View file

@ -1974,12 +1974,23 @@ function addUser(id, userinfo) {
else else
user.classList.remove('user-status-raisehand'); user.classList.remove('user-status-raisehand');
if(userinfo.username) {
let us = div.children; let us = div.children;
if(id === serverConnection.id) {
if(us.length === 0)
div.appendChild(user);
else
div.insertBefore(user, us[0]);
return;
}
if(userinfo.username) {
for(let i = 0; i < us.length; i++) { for(let i = 0; i < us.length; i++) {
let child = us[i]; let child = us[i];
let childuser = let childid = child.id.slice('user-'.length);
serverConnection.users[child.id.slice('user-'.length)] || null; if(childid === serverConnection.id)
continue;
let childuser = serverConnection.users[childid] || null;
let childname = (childuser && childuser.username) || null; let childname = (childuser && childuser.username) || null;
if(!childname || stringCompare(childname, userinfo.username) > 0) { if(!childname || stringCompare(childname, userinfo.username) > 0) {
div.insertBefore(user, child); div.insertBefore(user, child);
@ -1987,6 +1998,7 @@ function addUser(id, userinfo) {
} }
} }
} }
div.appendChild(user); div.appendChild(user);
} }