Skip to content

Commit

Permalink
fix profile media update
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Jun 7, 2024
1 parent bc237be commit 5060125
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/components/organisms/ProfileManage/ProfileManage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -40,7 +39,6 @@ export default function ProfileManage(props: IProps) {
const [bio, setBio] = React.useState<string>('');
const [banner, setBanner] = React.useState<any>(null);
const [avatar, setAvatar] = React.useState<any>(null);
const [usernameAsDisplayName, setUsernameAsDisplayName] = React.useState<boolean>(false);

const [loading, setLoading] = React.useState<boolean>(false);
const [profileResponse, setProfileResponse] = React.useState<NotificationType | null>(null);
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5060125

Please sign in to comment.