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 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', {
'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;
if (config.remove) {
removeBtn = h('span.fa.fa-times');
@ -2014,13 +2014,12 @@ define([
return;
}
loadingAvatar = true;
var newName = myData.name;
var newName = UI.getDisplayName(myData.name);
var url = myData.avatar;
$displayName.text(newName || Messages.anonymous);
$displayName.text(newName);
if ((accountName && oldUrl !== url) || !accountName && uid !== oldUid) {
$avatar.html('');
Common.displayAvatar($avatar, url,
newName || Messages.anonymous, function ($img) {
Common.displayAvatar($avatar, url, newName, function ($img) {
oldUrl = url;
oldUid = uid;
$userAdmin.find('> button').removeClass('cp-avatar');
@ -2310,7 +2309,8 @@ define([
var teams = Object.keys(privateData.teams).map(function (id) {
var data = privateData.teams[id];
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', {
'data-id': id,
title: data.name,
@ -3113,7 +3113,7 @@ define([
var sframeChan = common.getSframeChannel();
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 text = Messages._getKey('owner_add', [name, title]);
@ -3245,7 +3245,7 @@ define([
var sframeChan = common.getSframeChannel();
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 text = Messages._getKey('owner_team_add', [name, title]);
@ -3360,13 +3360,15 @@ define([
var verified = h('p');
var $verified = $(verified);
name = UI.getDisplayName(name);
if (priv.friends && priv.friends[curve]) {
$verified.addClass('cp-notifications-requestedit-verified');
var f = priv.friends[curve];
$verified.append(h('span.fa.fa-certificate'));
var $avatar = $(h('span.cp-avatar')).appendTo($verified);
$verified.append(h('p', Messages._getKey('isContact', [f.displayName])));
common.displayAvatar($avatar, f.avatar, f.displayName);
name = UI.getDisplayName(f.displayName);
$verified.append(h('p', Messages._getKey('isContact', [name])));
common.displayAvatar($avatar, f.avatar, name, Util.noop, f.uid);
} else {
$verified.append(Messages._getKey('isNotContact', [name]));
}
@ -3376,7 +3378,7 @@ define([
UIElements.displayInviteTeamModal = function (common, data) {
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 verified = UIElements.getVerifiedFriend(common, msg.author, name);
@ -3560,7 +3562,7 @@ define([
};
// Set the value to receive from the autocomplete
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+"]";
};
@ -3614,7 +3616,7 @@ define([
contenteditable: false
});
var displayName = (data.name || "").trim() || Messages.anonymous;
var displayName = UI.getDisplayName(data.name);
common.displayAvatar($(avatar), data.avatar, displayName); // XXX
return h('span.cp-mentions', {
'data-curve': data.curvePublic,
@ -3658,7 +3660,7 @@ define([
}).map(function (key) {
var data = sources[key];
return {
label: (data.name || "").trim() || Messages.anonymous,
label: UI.getDisplayName(data.name),
value: key
};
});
@ -3693,9 +3695,9 @@ define([
var obj = sources[key];
if (!obj) { return; }
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', [
avatar,
h('span', displayName),

@ -171,7 +171,7 @@ define([
if (!Object.keys(_friends).length) {
var friendText;
if (!friendKeys.length) {
console.error(UIElements.noContactsMessage(common));
//console.error(UIElements.noContactsMessage(common));
var findContacts = UIElements.noContactsMessage(common);
friendText = h('span.cp-app-prop-content',
findContacts.content
@ -772,7 +772,8 @@ define([
if (friend.edPublic !== ed || c === 'me') { return; }
_owners[friend.edPublic] = {
name: friend.displayName,
avatar: friend.avatar
avatar: friend.avatar,
uid: friend.uid,
};
return true;
})) {
@ -782,6 +783,10 @@ define([
_owners[ed] = {
avatar: '?',
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++;
});

Loading…
Cancel
Save