Sort typing members by display name

This commit is contained in:
miruka 2019-07-07 03:53:32 -04:00
parent 2923d440d0
commit 0ac4874ddf

View File

@ -2,16 +2,26 @@ Qt.include("../utils.js")
function typingTextFor(members, our_user_id) {
var names = []
var profiles = []
var names = []
for (var i = 0; i < members.length; i++) {
if (members[i] != our_user_id) {
names.push(coloredNameHtml(
users.getUser(members[i]).displayName, members[i]
))
profiles.push(users.getUser(members[i]))
}
}
profiles.sort(function(left, right) {
if (left.displayName < right.displayName) { return -1 }
if (left.displayName > right.displayName) { return +1 }
return 0
})
for (var i = 0; i < profiles.length; i++) {
var profile = profiles[i]
names.push(coloredNameHtml(profile.displayName, profile.userId))
}
if (names.length == 0) { return "" }
if (names.length == 1) { return qsTr("%1 is typing...").arg(names[0]) }