Hide avatar input for unregistered users
This commit is contained in:
parent
d493b95782
commit
6ea821a36e
3 changed files with 35 additions and 8 deletions
|
@ -724,13 +724,19 @@ export function useProfile(client) {
|
||||||
try {
|
try {
|
||||||
await client.setDisplayName(displayName);
|
await client.setDisplayName(displayName);
|
||||||
|
|
||||||
const url = await client.uploadContent(avatar);
|
let mxcAvatarUrl;
|
||||||
await client.setAvatarUrl(url);
|
|
||||||
|
if (avatar) {
|
||||||
|
mxcAvatarUrl = await client.uploadContent(avatar);
|
||||||
|
await client.setAvatarUrl(mxcAvatarUrl);
|
||||||
|
}
|
||||||
|
|
||||||
setState((prev) => ({
|
setState((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
displayName,
|
displayName,
|
||||||
avatarUrl: getAvatarUrl(client, url),
|
avatarUrl: mxcAvatarUrl
|
||||||
|
? getAvatarUrl(client, mxcAvatarUrl)
|
||||||
|
: prev.avatarUrl,
|
||||||
loading: false,
|
loading: false,
|
||||||
success: true,
|
success: true,
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -4,7 +4,13 @@ import { useProfile } from "./ConferenceCallManagerHooks";
|
||||||
import { FieldRow, InputField, ErrorMessage } from "./Input";
|
import { FieldRow, InputField, ErrorMessage } from "./Input";
|
||||||
import { Modal, ModalContent } from "./Modal";
|
import { Modal, ModalContent } from "./Modal";
|
||||||
|
|
||||||
export function ProfileModal({ client, ...rest }) {
|
export function ProfileModal({
|
||||||
|
client,
|
||||||
|
isAuthenticated,
|
||||||
|
isPasswordlessUser,
|
||||||
|
isGuest,
|
||||||
|
...rest
|
||||||
|
}) {
|
||||||
const { onClose } = rest;
|
const { onClose } = rest;
|
||||||
const {
|
const {
|
||||||
success,
|
success,
|
||||||
|
@ -60,9 +66,16 @@ export function ProfileModal({ client, ...rest }) {
|
||||||
onChange={onChangeDisplayName}
|
onChange={onChangeDisplayName}
|
||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
|
{isAuthenticated && !isGuest && !isPasswordlessUser && (
|
||||||
<FieldRow>
|
<FieldRow>
|
||||||
<InputField type="file" id="avatar" name="avatar" label="Avatar" />
|
<InputField
|
||||||
|
type="file"
|
||||||
|
id="avatar"
|
||||||
|
name="avatar"
|
||||||
|
label="Avatar"
|
||||||
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
|
)}
|
||||||
{error && (
|
{error && (
|
||||||
<FieldRow>
|
<FieldRow>
|
||||||
<ErrorMessage>{error.message}</ErrorMessage>
|
<ErrorMessage>{error.message}</ErrorMessage>
|
||||||
|
|
|
@ -108,7 +108,15 @@ export function UserMenu({ disableLogout }) {
|
||||||
</Menu>
|
</Menu>
|
||||||
)}
|
)}
|
||||||
</PopoverMenuTrigger>
|
</PopoverMenuTrigger>
|
||||||
{modalState.isOpen && <ProfileModal client={client} {...modalProps} />}
|
{modalState.isOpen && (
|
||||||
|
<ProfileModal
|
||||||
|
client={client}
|
||||||
|
isAuthenticated={isAuthenticated}
|
||||||
|
isGuest={isGuest}
|
||||||
|
isPasswordlessUser={isPasswordlessUser}
|
||||||
|
{...modalProps}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue