From 6ea821a36e86ae46aee9a8c2de84e63cde78d9e3 Mon Sep 17 00:00:00 2001 From: Robert Long Date: Fri, 17 Dec 2021 11:40:13 -0800 Subject: [PATCH] Hide avatar input for unregistered users --- src/ConferenceCallManagerHooks.jsx | 12 +++++++++--- src/ProfileModal.jsx | 21 +++++++++++++++++---- src/UserMenu.jsx | 10 +++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/ConferenceCallManagerHooks.jsx b/src/ConferenceCallManagerHooks.jsx index 2e5d32d..7a5a815 100644 --- a/src/ConferenceCallManagerHooks.jsx +++ b/src/ConferenceCallManagerHooks.jsx @@ -724,13 +724,19 @@ export function useProfile(client) { try { await client.setDisplayName(displayName); - const url = await client.uploadContent(avatar); - await client.setAvatarUrl(url); + let mxcAvatarUrl; + + if (avatar) { + mxcAvatarUrl = await client.uploadContent(avatar); + await client.setAvatarUrl(mxcAvatarUrl); + } setState((prev) => ({ ...prev, displayName, - avatarUrl: getAvatarUrl(client, url), + avatarUrl: mxcAvatarUrl + ? getAvatarUrl(client, mxcAvatarUrl) + : prev.avatarUrl, loading: false, success: true, })); diff --git a/src/ProfileModal.jsx b/src/ProfileModal.jsx index 3e86e86..9dd15f9 100644 --- a/src/ProfileModal.jsx +++ b/src/ProfileModal.jsx @@ -4,7 +4,13 @@ import { useProfile } from "./ConferenceCallManagerHooks"; import { FieldRow, InputField, ErrorMessage } from "./Input"; import { Modal, ModalContent } from "./Modal"; -export function ProfileModal({ client, ...rest }) { +export function ProfileModal({ + client, + isAuthenticated, + isPasswordlessUser, + isGuest, + ...rest +}) { const { onClose } = rest; const { success, @@ -60,9 +66,16 @@ export function ProfileModal({ client, ...rest }) { onChange={onChangeDisplayName} /> - - - + {isAuthenticated && !isGuest && !isPasswordlessUser && ( + + + + )} {error && ( {error.message} diff --git a/src/UserMenu.jsx b/src/UserMenu.jsx index e40b89b..0e6037d 100644 --- a/src/UserMenu.jsx +++ b/src/UserMenu.jsx @@ -108,7 +108,15 @@ export function UserMenu({ disableLogout }) { )} - {modalState.isOpen && } + {modalState.isOpen && ( + + )} ); }