diff --git a/src/Avatar.tsx b/src/Avatar.tsx index 1e1b8dbe..c11d71d4 100644 --- a/src/Avatar.tsx +++ b/src/Avatar.tsx @@ -16,7 +16,6 @@ limitations under the License. import { useMemo, CSSProperties, HTMLAttributes, FC } from "react"; import classNames from "classnames"; -import { MatrixClient } from "matrix-js-sdk/src/client"; import { getAvatarUrl } from "./matrix-utils"; import { useClient } from "./ClientContext"; @@ -59,9 +58,6 @@ function hashStringToArrIndex(str: string, arrLength: number) { return sum % arrLength; } -const resolveAvatarSrc = (client: MatrixClient, src: string, size: number) => - src?.startsWith("mxc://") ? client && getAvatarUrl(client, src, size) : src; - interface Props extends HTMLAttributes { bgKey?: string; src?: string; @@ -101,7 +97,7 @@ export const Avatar: FC = ({ const resolvedSrc = useMemo(() => { if (!client || !src || !sizePx) return undefined; - return resolveAvatarSrc(client, src, sizePx); + return src.startsWith("mxc://") ? getAvatarUrl(client, src, sizePx) : src; }, [client, src, sizePx]); const backgroundColor = useMemo(() => {