Display room avatars

This commit is contained in:
Robin Townsend
2022-05-18 19:00:59 -04:00
parent 183eea9f24
commit 24f721e414
12 changed files with 112 additions and 63 deletions

View File

@@ -15,7 +15,6 @@ limitations under the License.
*/
import { useState, useCallback, useEffect } from "react";
import { getAvatarUrl } from "../matrix-utils";
export function useProfile(client) {
const [{ loading, displayName, avatarUrl, error, success }, setState] =
@@ -26,7 +25,7 @@ export function useProfile(client) {
success: false,
loading: false,
displayName: user?.rawDisplayName,
avatarUrl: user && client && getAvatarUrl(client, user.avatarUrl),
avatarUrl: user?.avatarUrl,
error: null,
};
});
@@ -37,7 +36,7 @@ export function useProfile(client) {
success: false,
loading: false,
displayName,
avatarUrl: getAvatarUrl(client, avatarUrl),
avatarUrl,
error: null,
});
};
@@ -84,11 +83,7 @@ export function useProfile(client) {
setState((prev) => ({
...prev,
displayName,
avatarUrl: removeAvatar
? null
: mxcAvatarUrl
? getAvatarUrl(client, mxcAvatarUrl)
: prev.avatarUrl,
avatarUrl: removeAvatar ? null : mxcAvatarUrl ?? prev.avatarUrl,
loading: false,
success: true,
}));