animal emojis in the team roster

and fall back to default username in teams when members are unnamed
in various places where it was not handled
pull/1/head
ansuz 3 years ago
parent c4fcc9f732
commit 4b0cebb0fd

@ -693,6 +693,10 @@ define([
redrawRoster(common); redrawRoster(common);
}); });
}; };
var getDisplayName = function (name) {
return (typeof(name) === 'string'? name: "").trim() || Messages.anonymous;
};
var makeMember = function (common, data, me, roster) { var makeMember = function (common, data, me, roster) {
if (!data.curvePublic) { return; } if (!data.curvePublic) { return; }
@ -701,11 +705,12 @@ define([
return user.role === "OWNER" && user.curvePublic !== me.curvePublic && !user.pendingOwner; return user.role === "OWNER" && user.curvePublic !== me.curvePublic && !user.pendingOwner;
}); });
var displayName = getDisplayName(data.displayName);
// Avatar // Avatar
var avatar = h('span.cp-avatar.cp-team-member-avatar'); var avatar = h('span.cp-avatar.cp-team-member-avatar');
common.displayAvatar($(avatar), data.avatar, data.displayName); common.displayAvatar($(avatar), data.avatar, displayName, Util.noop, data.uid);
// Name // Name
var name = h('span.cp-team-member-name', data.displayName); var name = h('span.cp-team-member-name', displayName);
if (data.pendingOwner) { if (data.pendingOwner) {
$(name).append(h('em', { $(name).append(h('em', {
title: Messages.team_pendingOwnerTitle title: Messages.team_pendingOwnerTitle
@ -789,7 +794,7 @@ define([
title: Messages.team_rosterKick title: Messages.team_rosterKick
}); });
$(remove).click(function () { $(remove).click(function () {
UI.confirm(Messages._getKey('team_kickConfirm', [Util.fixHTML(data.displayName)]), function (yes) { UI.confirm(Messages._getKey('team_kickConfirm', [Util.fixHTML(displayName)]), function (yes) {
if (!yes) { return; } if (!yes) { return; }
APP.module.execCommand('REMOVE_USER', { APP.module.execCommand('REMOVE_USER', {
pending: data.pending, pending: data.pending,
@ -1073,6 +1078,9 @@ define([
metadata: obj metadata: obj
}, function () { }, function () {
$avatar.empty(); $avatar.empty();
// the UI is not supposed to allow admins to remove team names
// so we expect that it will be there. Failing that the initials
// from the default name will be displayed
common.displayAvatar($avatar, data.url); common.displayAvatar($avatar, data.url);
}); });
}); });
@ -1191,10 +1199,11 @@ define([
var displayUser = function (common, data) { var displayUser = function (common, data) {
var avatar = h('span.cp-teams-invite-from-avatar.cp-avatar'); var avatar = h('span.cp-teams-invite-from-avatar.cp-avatar');
common.displayAvatar($(avatar), data.avatar, data.displayName); var name = getDisplayName(data.displayName);
common.displayAvatar($(avatar), data.avatar, name);
return h('div.cp-teams-invite-from-author', [ return h('div.cp-teams-invite-from-author', [
avatar, avatar,
h('span.cp-teams-invite-from-name', data.displayName) h('span.cp-teams-invite-from-name', name)
]); ]);
}; };
@ -1319,20 +1328,21 @@ define([
nThen(function (waitFor) { nThen(function (waitFor) {
// Get preview content. // Get preview content.
sframeChan.query('Q_ANON_GET_PREVIEW_CONTENT', { seeds: seeds }, waitFor(function (err, json) { sframeChan.query('Q_ANON_GET_PREVIEW_CONTENT', { seeds: seeds }, waitFor(function (err, json) {
if (json && (json.error || !Object.keys(json).length)) { if (json && (json.error || !Object.keys(json).length)) { // XXX team invite links are triggering this every time for me?
$(errorBlock).text(Messages.team_inviteInvalidLinkError).show(); $(errorBlock).text(Messages.team_inviteInvalidLinkError).show();
waitFor.abort(); waitFor.abort();
$div.empty(); $div.empty();
return; return;
} }
// XXX nothing guarantees that author, teamName, or message exist in json
$div.empty(); $div.empty();
$div.append(h('div.cp-teams-invite-from', [ $div.append(h('div.cp-teams-invite-from', [
Messages.team_inviteFrom || 'From:', Messages.team_inviteFrom,
displayUser(common, json.author) displayUser(common, json.author)
])); ]));
$div.append(UI.setHTML(h('p.cp-teams-invite-to'), $div.append(UI.setHTML(h('p.cp-teams-invite-to'),
Messages._getKey('team_inviteFromMsg', Messages._getKey('team_inviteFromMsg',
[Util.fixHTML(json.author.displayName), [Util.fixHTML(getDisplayName(json.author.displayName)),
Util.fixHTML(json.teamName)]))); Util.fixHTML(json.teamName)])));
if (json.message) { if (json.message) {
$div.append(h('div.cp-teams-invite-message', json.message)); $div.append(h('div.cp-teams-invite-message', json.message));
@ -1449,10 +1459,10 @@ define([
// Update the name in the user menu // Update the name in the user menu
var $displayName = $bar.find('.' + Toolbar.constants.username); var $displayName = $bar.find('.' + Toolbar.constants.username);
metadataMgr.onChange(function () { metadataMgr.onChange(function () {
var name = metadataMgr.getUserData().name || Messages.anonymous; var name = getDisplayName(metadataMgr.getUserData().name);
$displayName.text(name); $displayName.text(name);
}); });
$displayName.text(user.name || Messages.anonymous); $displayName.text(getDisplayName(user.name));
// Load the Team module // Load the Team module
var onEvent = function (obj) { var onEvent = function (obj) {

Loading…
Cancel
Save