use emoji avatars in share and access modals

pull/1/head
ansuz 3 years ago
parent 95869b84c9
commit 7bb3bc167c

@ -156,11 +156,11 @@ define([
var icons = Object.keys(users).map(function (key, i) { var icons = Object.keys(users).map(function (key, i) {
var data = users[key]; var data = users[key];
var name = data.displayName || data.name || Messages.anonymous; var name = UI.getDisplayName(data.displayName || data.name);
var avatar = h('span.cp-usergrid-avatar.cp-avatar', { var avatar = h('span.cp-usergrid-avatar.cp-avatar', {
'aria-hidden': true, // XXX aria 'aria-hidden': true, // XXX aria
}); });
common.displayAvatar($(avatar), data.avatar, name); // XXX common.displayAvatar($(avatar), data.avatar, name, Util.noop, data.uid);
var removeBtn, el; var removeBtn, el;
if (config.remove) { if (config.remove) {
removeBtn = h('span.fa.fa-times'); removeBtn = h('span.fa.fa-times');
@ -2014,13 +2014,12 @@ define([
return; return;
} }
loadingAvatar = true; loadingAvatar = true;
var newName = myData.name; var newName = UI.getDisplayName(myData.name);
var url = myData.avatar; var url = myData.avatar;
$displayName.text(newName || Messages.anonymous); $displayName.text(newName);
if ((accountName && oldUrl !== url) || !accountName && uid !== oldUid) { if ((accountName && oldUrl !== url) || !accountName && uid !== oldUid) {
$avatar.html(''); $avatar.html('');
Common.displayAvatar($avatar, url, Common.displayAvatar($avatar, url, newName, function ($img) {
newName || Messages.anonymous, function ($img) {
oldUrl = url; oldUrl = url;
oldUid = uid; oldUid = uid;
$userAdmin.find('> button').removeClass('cp-avatar'); $userAdmin.find('> button').removeClass('cp-avatar');
@ -2310,7 +2309,8 @@ define([
var teams = Object.keys(privateData.teams).map(function (id) { var teams = Object.keys(privateData.teams).map(function (id) {
var data = privateData.teams[id]; var data = privateData.teams[id];
var avatar = h('span.cp-creation-team-avatar.cp-avatar'); var avatar = h('span.cp-creation-team-avatar.cp-avatar');
common.displayAvatar($(avatar), data.avatar, data.name); // XXX // We assume that teams always have a non-empty name, so we don't need a UID
common.displayAvatar($(avatar), data.avatar, data.name);
return h('div.cp-creation-team', { return h('div.cp-creation-team', {
'data-id': id, 'data-id': id,
title: data.name, title: data.name,
@ -3113,7 +3113,7 @@ define([
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var msg = data.content.msg; var msg = data.content.msg;
var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; var name = Util.fixHTML(UI.getDisplayName(msg.content.user.displayName));
var title = Util.fixHTML(msg.content.title); var title = Util.fixHTML(msg.content.title);
var text = Messages._getKey('owner_add', [name, title]); var text = Messages._getKey('owner_add', [name, title]);
@ -3245,7 +3245,7 @@ define([
var sframeChan = common.getSframeChannel(); var sframeChan = common.getSframeChannel();
var msg = data.content.msg; var msg = data.content.msg;
var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; var name = Util.fixHTML(UI.getDisplayName(msg.content.user.displayName));
var title = Util.fixHTML(msg.content.title); var title = Util.fixHTML(msg.content.title);
var text = Messages._getKey('owner_team_add', [name, title]); var text = Messages._getKey('owner_team_add', [name, title]);
@ -3360,13 +3360,15 @@ define([
var verified = h('p'); var verified = h('p');
var $verified = $(verified); var $verified = $(verified);
name = UI.getDisplayName(name);
if (priv.friends && priv.friends[curve]) { if (priv.friends && priv.friends[curve]) {
$verified.addClass('cp-notifications-requestedit-verified'); $verified.addClass('cp-notifications-requestedit-verified');
var f = priv.friends[curve]; var f = priv.friends[curve];
$verified.append(h('span.fa.fa-certificate')); $verified.append(h('span.fa.fa-certificate'));
var $avatar = $(h('span.cp-avatar')).appendTo($verified); var $avatar = $(h('span.cp-avatar')).appendTo($verified);
$verified.append(h('p', Messages._getKey('isContact', [f.displayName]))); name = UI.getDisplayName(f.displayName);
common.displayAvatar($avatar, f.avatar, f.displayName); $verified.append(h('p', Messages._getKey('isContact', [name])));
common.displayAvatar($avatar, f.avatar, name, Util.noop, f.uid);
} else { } else {
$verified.append(Messages._getKey('isNotContact', [name])); $verified.append(Messages._getKey('isNotContact', [name]));
} }
@ -3376,7 +3378,7 @@ define([
UIElements.displayInviteTeamModal = function (common, data) { UIElements.displayInviteTeamModal = function (common, data) {
var msg = data.content.msg; var msg = data.content.msg;
var name = Util.fixHTML(msg.content.user.displayName) || Messages.anonymous; var name = Util.fixHTML(UI.getDisplayName(msg.content.user.displayName));
var teamName = Util.fixHTML(Util.find(msg, ['content', 'team', 'metadata', 'name']) || ''); var teamName = Util.fixHTML(Util.find(msg, ['content', 'team', 'metadata', 'name']) || '');
var verified = UIElements.getVerifiedFriend(common, msg.author, name); var verified = UIElements.getVerifiedFriend(common, msg.author, name);
@ -3560,7 +3562,7 @@ define([
}; };
// Set the value to receive from the autocomplete // Set the value to receive from the autocomplete
var toInsert = function (data, key) { var toInsert = function (data, key) {
var name = (data.name.replace(/[^a-zA-Z0-9]+/g, "-") || "").trim() || Messages.anonymous; // XXX var name = UI.getDisplayName(data.name.replace(/[^a-zA-Z0-9]+/g, "-"));
return "[@"+name+"|"+key+"]"; return "[@"+name+"|"+key+"]";
}; };
@ -3614,7 +3616,7 @@ define([
contenteditable: false contenteditable: false
}); });
var displayName = (data.name || "").trim() || Messages.anonymous; var displayName = UI.getDisplayName(data.name);
common.displayAvatar($(avatar), data.avatar, displayName); // XXX common.displayAvatar($(avatar), data.avatar, displayName); // XXX
return h('span.cp-mentions', { return h('span.cp-mentions', {
'data-curve': data.curvePublic, 'data-curve': data.curvePublic,
@ -3658,7 +3660,7 @@ define([
}).map(function (key) { }).map(function (key) {
var data = sources[key]; var data = sources[key];
return { return {
label: (data.name || "").trim() || Messages.anonymous, label: UI.getDisplayName(data.name),
value: key value: key
}; };
}); });
@ -3693,9 +3695,9 @@ define([
var obj = sources[key]; var obj = sources[key];
if (!obj) { return; } if (!obj) { return; }
var avatar = h('span.cp-avatar'); var avatar = h('span.cp-avatar');
var displayName = (obj.name || "").trim() || Messages.anonymous; var displayName = UI.getDisplayName(obj.name);
common.displayAvatar($(avatar), obj.avatar, displayName, Util.noop, obj.uid); // XXX common.displayAvatar($(avatar), obj.avatar, displayName, Util.noop, obj.uid);
var li = h('li.cp-autocomplete-value', [ var li = h('li.cp-autocomplete-value', [
avatar, avatar,
h('span', displayName), h('span', displayName),

@ -171,7 +171,7 @@ define([
if (!Object.keys(_friends).length) { if (!Object.keys(_friends).length) {
var friendText; var friendText;
if (!friendKeys.length) { if (!friendKeys.length) {
console.error(UIElements.noContactsMessage(common)); //console.error(UIElements.noContactsMessage(common));
var findContacts = UIElements.noContactsMessage(common); var findContacts = UIElements.noContactsMessage(common);
friendText = h('span.cp-app-prop-content', friendText = h('span.cp-app-prop-content',
findContacts.content findContacts.content
@ -772,7 +772,8 @@ define([
if (friend.edPublic !== ed || c === 'me') { return; } if (friend.edPublic !== ed || c === 'me') { return; }
_owners[friend.edPublic] = { _owners[friend.edPublic] = {
name: friend.displayName, name: friend.displayName,
avatar: friend.avatar avatar: friend.avatar,
uid: friend.uid,
}; };
return true; return true;
})) { })) {
@ -782,6 +783,10 @@ define([
_owners[ed] = { _owners[ed] = {
avatar: '?', avatar: '?',
name: Messages.owner_unknownUser, name: Messages.owner_unknownUser,
// TODO a possible enhancement is to use data from the context
// ie. if you have opened the access modal from within the pad
// its owner might be present or they might have left some data
// in the pad itself (as is the case of the uid in rich text comments)
}; };
strangers++; strangers++;
}); });

Loading…
Cancel
Save