mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Merge pull request #5043 from node-red/5036-fix-undefined-username
Handle undefined username when generating user icon
This commit is contained in:
commit
16d25b9d41
@ -398,14 +398,13 @@ RED.multiplayer = (function () {
|
|||||||
anonIconBody.setAttribute("d",`M ${radius/2} ${radius/2 + 5} h -2.5 c -2 1 -2 -5 0.5 -4.5 c 2 1 2 1 4 0 c 2.5 -0.5 2.5 5.5 0 4.5 z`);
|
anonIconBody.setAttribute("d",`M ${radius/2} ${radius/2 + 5} h -2.5 c -2 1 -2 -5 0.5 -4.5 c 2 1 2 1 4 0 c 2.5 -0.5 2.5 5.5 0 4.5 z`);
|
||||||
group.appendChild(anonIconBody)
|
group.appendChild(anonIconBody)
|
||||||
} else {
|
} else {
|
||||||
const labelText = user.username ? user.username.substring(0,2) : user
|
|
||||||
const label = document.createElementNS("http://www.w3.org/2000/svg","text");
|
const label = document.createElementNS("http://www.w3.org/2000/svg","text");
|
||||||
if (user.username) {
|
if (user.username || user.email) {
|
||||||
label.setAttribute("class","red-ui-multiplayer-annotation-label");
|
label.setAttribute("class","red-ui-multiplayer-annotation-label");
|
||||||
label.textContent = user.username.substring(0,2)
|
label.textContent = (user.username || user.email).substring(0,2)
|
||||||
} else {
|
} else {
|
||||||
label.setAttribute("class","red-ui-multiplayer-annotation-label red-ui-multiplayer-user-count")
|
label.setAttribute("class","red-ui-multiplayer-annotation-label red-ui-multiplayer-user-count")
|
||||||
label.textContent = user
|
label.textContent = 'nr'
|
||||||
}
|
}
|
||||||
label.setAttribute("text-anchor", "middle")
|
label.setAttribute("text-anchor", "middle")
|
||||||
label.setAttribute("x",radius/2);
|
label.setAttribute("x",radius/2);
|
||||||
|
@ -351,10 +351,10 @@ RED.user = (function() {
|
|||||||
userIcon.css({
|
userIcon.css({
|
||||||
backgroundImage: "url("+user.image+")",
|
backgroundImage: "url("+user.image+")",
|
||||||
})
|
})
|
||||||
} else if (user.anonymous) {
|
} else if (user.anonymous || (!user.username && !user.email)) {
|
||||||
$('<i class="fa fa-user"></i>').appendTo(userIcon);
|
$('<i class="fa fa-user"></i>').appendTo(userIcon);
|
||||||
} else {
|
} else {
|
||||||
$('<span>').text(user.username.substring(0,2)).appendTo(userIcon);
|
$('<span>').text((user.username || user.email).substring(0,2)).appendTo(userIcon);
|
||||||
}
|
}
|
||||||
if (user.profileColor !== undefined) {
|
if (user.profileColor !== undefined) {
|
||||||
userIcon.addClass('red-ui-user-profile-color-' + user.profileColor)
|
userIcon.addClass('red-ui-user-profile-color-' + user.profileColor)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user