Refactor RoomAvatar into a functional component. (#29743)

* Refactor RoomAvatar into a functional component

* Add useRoomAvatar hook

* Remove useRoomAvatar hook and fix RoomAvatarEvents not using thumbnails.

* lint

* Ensure stable version of roomIdName

* Use new hook

* lint

* remove unused param

* Fixup tests

* remove console

* Update test
This commit is contained in:
Will Hunt
2025-04-15 09:23:26 +00:00
committed by GitHub
parent c313c720de
commit 6fc3dd4628
8 changed files with 128 additions and 133 deletions
+4 -3
View File
@@ -147,11 +147,12 @@ export function avatarUrlForRoom(
width?: number,
height?: number,
resizeMethod?: ResizeMethod,
avatarMxcOverride?: string,
): string | null {
if (!room) return null; // null-guard
if (room.getMxcAvatarUrl()) {
const media = mediaFromMxc(room.getMxcAvatarUrl() ?? undefined);
const mxc = avatarMxcOverride ?? room.getMxcAvatarUrl();
if (mxc) {
const media = mediaFromMxc(mxc);
if (width !== undefined && height !== undefined) {
return media.getThumbnailOfSourceHttp(width, height, resizeMethod);
}