From 5060125f0bc0aa780d5e21187d28ebdb1e6ad186 Mon Sep 17 00:00:00 2001 From: NickJ202 Date: Fri, 7 Jun 2024 08:37:56 +0200 Subject: [PATCH] fix profile media update --- .../organisms/ProfileManage/ProfileManage.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/organisms/ProfileManage/ProfileManage.tsx b/src/components/organisms/ProfileManage/ProfileManage.tsx index 3ec7689..184387f 100644 --- a/src/components/organisms/ProfileManage/ProfileManage.tsx +++ b/src/components/organisms/ProfileManage/ProfileManage.tsx @@ -7,7 +7,6 @@ import { createTransaction, messageResult } from 'api'; import { getGQLData } from 'gql'; import { Button } from 'components/atoms/Button'; -import { Checkbox } from 'components/atoms/Checkbox'; import { FormField } from 'components/atoms/FormField'; import { Notification } from 'components/atoms/Notification'; import { TextArea } from 'components/atoms/TextArea'; @@ -40,7 +39,6 @@ export default function ProfileManage(props: IProps) { const [bio, setBio] = React.useState(''); const [banner, setBanner] = React.useState(null); const [avatar, setAvatar] = React.useState(null); - const [usernameAsDisplayName, setUsernameAsDisplayName] = React.useState(false); const [loading, setLoading] = React.useState(false); const [profileResponse, setProfileResponse] = React.useState(null); @@ -50,15 +48,11 @@ export default function ProfileManage(props: IProps) { setUsername(props.profile.username ?? ''); setName(props.profile.displayName ?? ''); setBio(props.profile.bio ?? ''); - setBanner(props.profile.banner ?? null); - setAvatar(props.profile.avatar ?? null); + setBanner(props.profile.banner && checkAddress(props.profile.banner) ? props.profile.banner : null); + setAvatar(props.profile.avatar && checkAddress(props.profile.avatar) ? props.profile.avatar : null); } }, [props.profile]); - React.useEffect(() => { - if (usernameAsDisplayName) setName(username); - }, [usernameAsDisplayName, username]); - function handleUpdate() { arProvider.setToggleProfileUpdate(!arProvider.toggleProfileUpdate); if (props.handleUpdate) props.handleUpdate(); @@ -116,8 +110,8 @@ export default function ProfileManage(props: IProps) { } } - if (bannerTx) data.CoverImage = bannerTx; - if (avatarTx) data.ProfileImage = avatarTx; + data.CoverImage = bannerTx || 'None'; + data.ProfileImage = avatarTx || 'None'; try { if (props.profile && props.profile.id) { @@ -373,7 +367,7 @@ export default function ProfileManage(props: IProps) { label={language.name} value={name} onChange={(e: any) => setName(e.target.value)} - disabled={loading || usernameAsDisplayName} + disabled={loading} invalid={{ status: false, message: null }} required hideErrorMessage