resolve minor comments and clean up

pull/1/head
ansuz 3 years ago
parent 147ddd88bf
commit 0ac368a5c9

@ -18,7 +18,7 @@ define([
curvePublic: proxy.curvePublic, curvePublic: proxy.curvePublic,
notifications: Util.find(proxy, ['mailboxes', 'notifications', 'channel']), notifications: Util.find(proxy, ['mailboxes', 'notifications', 'channel']),
avatar: proxy.profile && proxy.profile.avatar, avatar: proxy.profile && proxy.profile.avatar,
uid: proxy.uid, // XXX test without this and see if it breaks things uid: proxy.uid,
}; };
if (hash === false) { delete data.channel; } if (hash === false) { delete data.channel; }
return data; return data;

@ -1991,7 +1991,7 @@ define([
var $displayName = $userAdmin.find('.'+displayNameCls); var $displayName = $userAdmin.find('.'+displayNameCls);
var $avatar = $userAdmin.find('> button .cp-dropdown-button-title'); // XXX alt="User menu" var $avatar = $userAdmin.find('> button .cp-dropdown-button-title');
var loadingAvatar; var loadingAvatar;
var to; var to;
var oldUrl = ''; var oldUrl = '';

@ -90,17 +90,12 @@ define([
// https://emojipedia.org/nature/ // https://emojipedia.org/nature/
var ANIMALS = AppConfig.emojiAvatars || []; var ANIMALS = AppConfig.emojiAvatars || [];
var getRandomAnimal = function () { // XXX should never actually happen?
if (!ANIMALS.length) { return ''; }
return ANIMALS[Math.floor(Math.random() * ANIMALS.length)];
};
var getPseudorandomAnimal = MT.getPseudorandomAnimal = function (seed) { var getPseudorandomAnimal = MT.getPseudorandomAnimal = function (seed) {
if (!ANIMALS.length) { return ''; } if (!ANIMALS.length) { return ''; }
if (typeof(seed) !== 'string') { return getRandomAnimal(); } if (typeof(seed) !== 'string') { return; }
seed = seed.replace(/\D/g, '').slice(0, 10); // XXX possible optimization for on-wire uid seed = seed.replace(/\D/g, '').slice(0, 10); // TODO possible optimization for on-wire uid
seed = parseInt(seed); seed = parseInt(seed);
if (!seed) { return getRandomAnimal(); } if (!seed) { return; }
return ANIMALS[seed % ANIMALS.length] || ''; return ANIMALS[seed % ANIMALS.length] || '';
}; };
@ -141,7 +136,7 @@ define([
var $avatar = $('<span>', { var $avatar = $('<span>', {
'class': 'cp-avatar-default' + (animal_avatar? ' animal': ''), 'class': 'cp-avatar-default' + (animal_avatar? ' animal': ''),
// XXX prevents screenreaders from trying to describe this // this prevents screenreaders from trying to describe this
alt: '', alt: '',
'aria-hidden': true, 'aria-hidden': true,
}).text(text); }).text(text);
@ -196,7 +191,7 @@ define([
var $img = $(mt).appendTo($container); var $img = $(mt).appendTo($container);
MT.displayMediatagImage(common, $img, function (err, $image) { MT.displayMediatagImage(common, $img, function (err, $image) {
if (err) { return void console.error(err); } if (err) { return void console.error(err); }
centerImage($img, $image); // XXX add alt="" (unless the media-tag has an alt attr) centerImage($img, $image);
}); });
}); });
} }

@ -235,9 +235,6 @@ define([
}; };
}; };
funcs.getAuthorId = function () { // XXX
};
var authorUid = function(existing) { var authorUid = function(existing) {
if (!Array.isArray(existing)) { existing = []; } if (!Array.isArray(existing)) { existing = []; }
var n; var n;
@ -263,7 +260,7 @@ define([
}); });
return uid || authorUid(existing); return uid || authorUid(existing);
} }
// XXX this should check for a matching curvePublic / uid if: // TODO this should check for a matching curvePublic / uid if:
// 1. you are logged in OR // 1. you are logged in OR
// 2. you have a token // 2. you have a token
// so that users that register recognize comments from before // so that users that register recognize comments from before

@ -164,6 +164,7 @@ MessengerUI, Messages, Pages) {
}); });
}; };
var showColors = false; var showColors = false;
Messages.userlist_visitProfile = "Visit {0}'s profile"; // XXX "'s" is incorrect for names that end in "s" in English... don't care?
var updateUserList = function (toolbar, config, forceOffline) { var updateUserList = function (toolbar, config, forceOffline) {
if (!config.displayed || config.displayed.indexOf('userlist') === -1) { return; } if (!config.displayed || config.displayed.indexOf('userlist') === -1) { return; }
if (toolbar.isAlone) { return; } if (toolbar.isAlone) { return; }
@ -249,6 +250,7 @@ MessengerUI, Messages, Pages) {
var friendRequests = Common.getFriendRequests(); // Friend requests received var friendRequests = Common.getFriendRequests(); // Friend requests received
editUsersNames.forEach(function (data) { editUsersNames.forEach(function (data) {
var name = data.name || Messages.anonymous; var name = data.name || Messages.anonymous;
var safeName = Util.fixHTML(name);
var $span = $('<span>', {'class': 'cp-avatar'}); var $span = $('<span>', {'class': 'cp-avatar'});
if (data.color && showColors) { if (data.color && showColors) {
$span.css('border-color', data.color); $span.css('border-color', data.color);
@ -323,7 +325,7 @@ MessengerUI, Messages, Pages) {
$('<button>', { $('<button>', {
'class': 'fa fa-bell cp-toolbar-userlist-button', 'class': 'fa fa-bell cp-toolbar-userlist-button',
'data-cptippy-html': true, 'data-cptippy-html': true,
'title': Messages._getKey('friendRequest_received', [Util.fixHTML(name)]), 'title': Messages._getKey('friendRequest_received', [safeName]),
}).appendTo($nameSpan).click(function (e) { }).appendTo($nameSpan).click(function (e) {
e.stopPropagation(); e.stopPropagation();
UIElements.displayFriendRequestModal(Common, friendRequests[data.curvePublic]); UIElements.displayFriendRequestModal(Common, friendRequests[data.curvePublic]);
@ -334,7 +336,7 @@ MessengerUI, Messages, Pages) {
'class': 'fa fa-user-plus cp-toolbar-userlist-button', 'class': 'fa fa-user-plus cp-toolbar-userlist-button',
'data-cptippy-html': true, 'data-cptippy-html': true,
'title': Messages._getKey('userlist_addAsFriendTitle', [ 'title': Messages._getKey('userlist_addAsFriendTitle', [
Util.fixHTML(name) safeName,
]) ])
}).appendTo($nameSpan).click(function (e) { }).appendTo($nameSpan).click(function (e) {
e.stopPropagation(); e.stopPropagation();
@ -356,9 +358,9 @@ MessengerUI, Messages, Pages) {
}); });
} }
if (data.profile) { if (data.profile) {
// XXX title to visit their profile "Visit {0}'s profile"
// Messages.contacts_info3 "Double-click their icon to view their profile", // Messages.contacts_info3 "Double-click their icon to view their profile",
$span.addClass('cp-userlist-clickable'); $span.addClass('cp-userlist-clickable');
$span.attr('title', Messages._getKey('userlist_visitProfile', [name]));
$span.click(function () { $span.click(function () {
Common.openURL(origin+'/profile/#' + data.profile); Common.openURL(origin+'/profile/#' + data.profile);
}); });

@ -42,7 +42,7 @@ define([
var cursors = {}; var cursors = {};
// XXX despite the name of this function this doesn't actually render as a tippy tooltip // FIXME despite the name of this function this doesn't actually render as a tippy tooltip
// that means that emojis will use the system font that shows up in native tooltips // that means that emojis will use the system font that shows up in native tooltips
// so this might be of limited value/aesthetic appeal compared to other apps' cursors // so this might be of limited value/aesthetic appeal compared to other apps' cursors
var makeTippy = function (cursor) { var makeTippy = function (cursor) {

Loading…
Cancel
Save