Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

people: Add small_avatar_url_for_user_id helper.

Aman Agrawal3ed78a96ad65
diff --git a/web/src/people.ts b/web/src/people.ts
index b82137b19e9..09911c4c1f2 100644
--- a/web/src/people.ts
+++ b/web/src/people.ts
@@ -909,6 +909,10 @@ export function small_avatar_url_for_person(person: User | CurrentUser): string
return `/avatar/${person.user_id}`;
}
+export function small_avatar_url_for_user_id(user_id: number): string {
+ return small_avatar_url_for_person(get_by_user_id(user_id));
+}
+
export function medium_avatar_url_for_person(person: User): string {
/* Unlike the small avatar URL case, we don't generally have a
* medium avatar URL included in person objects. So only have the
diff --git a/web/tests/people.test.cjs b/web/tests/people.test.cjs
index 0450546eaf7..84b0d79d5de 100644
--- a/web/tests/people.test.cjs
+++ b/web/tests/people.test.cjs
@@ -1043,6 +1043,9 @@ run_test("message_methods", () => {
maria.avatar_url,
"https://secure.gravatar.com/avatar/6dbdd7946b58d8b11351fcb27e5cdd55?d=identicon",
);
+ // small_avatar_url_for_user_id delegates to small_avatar_url_for_person.
+ assert.equal(people.small_avatar_url_for_user_id(maria.user_id), maria.avatar_url);
+
// This will use the cached gravatar url
assert.equal(
people.medium_avatar_url_for_person(maria),