mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
people: Extract small_avatar_url_for_person.
This is intended to be used in places like compose typeahead to display users' avatars.
This commit is contained in:
@@ -381,6 +381,8 @@ initialize();
|
||||
people.add(charles);
|
||||
people.add(maria);
|
||||
|
||||
assert.equal(people.small_avatar_url_for_person(maria),
|
||||
'https://secure.gravatar.com/avatar/md5-athens@example.com?d=identicon&s=50');
|
||||
var message = {
|
||||
type: 'private',
|
||||
display_recipient: [
|
||||
|
||||
@@ -496,6 +496,13 @@ function gravatar_url_for_email(email) {
|
||||
return small_avatar_url;
|
||||
}
|
||||
|
||||
exports.small_avatar_url_for_person = function (person) {
|
||||
if (person.avatar_url) {
|
||||
return exports.format_small_avatar_url(person.avatar_url);
|
||||
}
|
||||
return gravatar_url_for_email(person.email);
|
||||
};
|
||||
|
||||
exports.small_avatar_url = function (message) {
|
||||
// Try to call this function in all places where we need 25px
|
||||
// avatar images, so that the browser can help
|
||||
@@ -519,9 +526,8 @@ exports.small_avatar_url = function (message) {
|
||||
|
||||
// The first time we encounter a sender in a message, we may
|
||||
// not have person.avatar_url set, but if we do, then use that.
|
||||
if (person) {
|
||||
url = person.avatar_url;
|
||||
email = person.email;
|
||||
if (person && person.avatar_url) {
|
||||
return exports.small_avatar_url_for_person(person);
|
||||
}
|
||||
|
||||
// Try to get info from the message if we didn't have a `person` object
|
||||
|
||||
Reference in New Issue
Block a user