diff --git a/static/sfu.js b/static/sfu.js index dabbb25..b352cc3 100644 --- a/static/sfu.js +++ b/static/sfu.js @@ -1067,6 +1067,25 @@ function resizePeers() { /** @type{Object} */ let users = {}; +/** + * Lexicographic order, with case differences secondary. + * @param{string} a + * @param{string} b + */ +function stringCompare(a, b) { + let la = a.toLowerCase() + let lb = b.toLowerCase() + if(la < lb) + return -1; + else if(la > lb) + return +1; + else if(a < b) + return -1; + else if(a > b) + return +1; + return 0 +} + /** * @param {string} id * @param {string} name @@ -1088,8 +1107,8 @@ function addUser(id, name) { let us = div.children; for(let i = 0; i < us.length; i++) { let child = us[i]; - let childname = users[child.id.slice('user-'.length)]; - if(!childname || childname > name) { + let childname = users[child.id.slice('user-'.length)] || null; + if(!childname || stringCompare(childname, name) > 0) { div.insertBefore(user, child); return; }