From 493445a6b0c9e8bf303279821ebd44bfe71cdb17 Mon Sep 17 00:00:00 2001 From: Robert Long Date: Mon, 20 Dec 2021 09:12:28 -0800 Subject: [PATCH] Update user avatars --- src/Avatar.module.css | 1 + src/CallList.jsx | 9 ++++++--- src/ConferenceCallManagerHooks.jsx | 2 +- src/Facepile.jsx | 25 +++++++++++++++---------- src/Home.jsx | 12 ++++++++++-- src/Room.jsx | 26 ++++++++++++++++++++++++++ src/Room.module.css | 7 +++++++ src/UserMenu.jsx | 1 - 8 files changed, 66 insertions(+), 17 deletions(-) diff --git a/src/Avatar.module.css b/src/Avatar.module.css index 374024d..516dca1 100644 --- a/src/Avatar.module.css +++ b/src/Avatar.module.css @@ -7,6 +7,7 @@ pointer-events: none; font-weight: 600; overflow: hidden; + flex-shrink: 0; } .avatar img { diff --git a/src/CallList.jsx b/src/CallList.jsx index fee71d7..63cd8e5 100644 --- a/src/CallList.jsx +++ b/src/CallList.jsx @@ -7,7 +7,7 @@ import { ReactComponent as VideoIcon } from "./icons/Video.svg"; import styles from "./CallList.module.css"; import { getRoomUrl } from "./ConferenceCallManagerHooks"; -export function CallList({ title, rooms }) { +export function CallList({ title, rooms, client }) { return ( <>

{title}

@@ -15,6 +15,7 @@ export function CallList({ title, rooms }) { {rooms.map(({ roomId, roomName, avatarUrl, participants }) => ( @@ -40,7 +41,9 @@ function CallTile({ name, avatarUrl, roomId, participants }) {
{name}

{getRoomUrl(roomId)}

- {participants && } + {participants && ( + + )}
diff --git a/src/ConferenceCallManagerHooks.jsx b/src/ConferenceCallManagerHooks.jsx index cd7b1d9..51583c2 100644 --- a/src/ConferenceCallManagerHooks.jsx +++ b/src/ConferenceCallManagerHooks.jsx @@ -624,7 +624,7 @@ export function getRoomUrl(roomId) { } } -function getAvatarUrl(client, mxcUrl, avatarSize = 96) { +export function getAvatarUrl(client, mxcUrl, avatarSize = 96) { const width = Math.floor(avatarSize * window.devicePixelRatio); const height = Math.floor(avatarSize * window.devicePixelRatio); return mxcUrl && client.mxcUrlToHttp(mxcUrl, width, height, "crop"); diff --git a/src/Facepile.jsx b/src/Facepile.jsx index c87fff6..bc084e4 100644 --- a/src/Facepile.jsx +++ b/src/Facepile.jsx @@ -2,23 +2,28 @@ import React from "react"; import styles from "./Facepile.module.css"; import classNames from "classnames"; import { Avatar } from "./Avatar"; +import { getAvatarUrl } from "./ConferenceCallManagerHooks"; -export function Facepile({ className, participants, ...rest }) { +export function Facepile({ className, client, participants, ...rest }) { return (
member.name).join(", ")} {...rest} > - {participants.slice(0, 3).map((member, i) => ( - - ))} + {participants.slice(0, 3).map((member, i) => { + const avatarUrl = member.user?.avatarUrl; + return ( + + ); + })} {participants.length > 3 && (
{publicRooms.length > 0 && ( - + )} {recentRooms.length > 0 && ( - + )}
diff --git a/src/Room.jsx b/src/Room.jsx index 90b8373..9fe8ab0 100644 --- a/src/Room.jsx +++ b/src/Room.jsx @@ -37,6 +37,7 @@ import { useGroupCall } from "matrix-react-sdk/src/hooks/useGroupCall"; import { useCallFeed } from "matrix-react-sdk/src/hooks/useCallFeed"; import { useMediaStream } from "matrix-react-sdk/src/hooks/useMediaStream"; import { + getAvatarUrl, getRoomUrl, useClient, useLoadGroupCall, @@ -49,6 +50,7 @@ import { OverflowMenu } from "./OverflowMenu"; import { GridLayoutMenu } from "./GridLayoutMenu"; import { UserMenu } from "./UserMenu"; import classNames from "classnames"; +import { Avatar } from "./Avatar"; const canScreenshare = "getDisplayMedia" in navigator.mediaDevices; // There is currently a bug in Safari our our code with cloning and sending MediaStreams @@ -445,6 +447,29 @@ function InRoomView({ [layout, setLayout] ); + const renderAvatar = useCallback( + (roomMember, width, height) => { + const avatarUrl = roomMember.user?.avatarUrl; + const size = Math.round(Math.min(width, height) / 2); + + return ( + + ); + }, + [client] + ); + return (
@@ -466,6 +491,7 @@ function InRoomView({ diff --git a/src/Room.module.css b/src/Room.module.css index 7517bfd..d6ec2c0 100644 --- a/src/Room.module.css +++ b/src/Room.module.css @@ -195,6 +195,13 @@ limitations under the License. max-width: 360px; } +.avatar { + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); +} + @media (min-width: 800px) { .roomContainer { flex-direction: row; diff --git a/src/UserMenu.jsx b/src/UserMenu.jsx index a79b142..a6d5d07 100644 --- a/src/UserMenu.jsx +++ b/src/UserMenu.jsx @@ -93,7 +93,6 @@ export function UserMenu({ disableLogout }) { size="sm" src={avatarUrl} fallback={(displayName || userName).slice(0, 1).toUpperCase()} - className={styles.avatar} /> ) : (