Fix save profile avatar disappearing on save name/bio
This commit is contained in:
parent
4a73b48f3f
commit
cf9a376df8
5 changed files with 34 additions and 38 deletions
|
@ -7,7 +7,7 @@ import type { AvatarColorType } from '../types/Colors';
|
|||
import { AvatarColors } from '../types/Colors';
|
||||
import type {
|
||||
AvatarDataType,
|
||||
AvatarUpdateType,
|
||||
AvatarUpdateOptionsType,
|
||||
DeleteAvatarFromDiskActionType,
|
||||
ReplaceAvatarActionType,
|
||||
SaveAvatarToDiskActionType,
|
||||
|
@ -59,7 +59,7 @@ type PropsExternalType = {
|
|||
onEditStateChanged: (editState: EditState) => unknown;
|
||||
onProfileChanged: (
|
||||
profileData: ProfileDataType,
|
||||
avatar: AvatarUpdateType
|
||||
avatarUpdateOptions: AvatarUpdateOptionsType
|
||||
) => unknown;
|
||||
renderEditUsernameModalBody: (props: {
|
||||
isRootModal: boolean;
|
||||
|
@ -199,9 +199,6 @@ export function ProfileEditor({
|
|||
const [avatarBuffer, setAvatarBuffer] = useState<Uint8Array | undefined>(
|
||||
undefined
|
||||
);
|
||||
const [isLoadingAvatar, setIsLoadingAvatar] = useState(
|
||||
Boolean(profileAvatarPath)
|
||||
);
|
||||
const [stagedProfile, setStagedProfile] = useState<ProfileDataType>({
|
||||
aboutEmoji,
|
||||
aboutText,
|
||||
|
@ -252,7 +249,10 @@ export function ProfileEditor({
|
|||
? trim(stagedProfile.familyName)
|
||||
: undefined,
|
||||
},
|
||||
{ oldAvatar: oldAvatarBuffer, newAvatar: avatar }
|
||||
{
|
||||
keepAvatar: false,
|
||||
avatarUpdate: { oldAvatar: oldAvatarBuffer, newAvatar: avatar },
|
||||
}
|
||||
);
|
||||
setOldAvatarBuffer(avatar);
|
||||
},
|
||||
|
@ -289,9 +289,8 @@ export function ProfileEditor({
|
|||
avatar => {
|
||||
setAvatarBuffer(avatar);
|
||||
setOldAvatarBuffer(avatar);
|
||||
setIsLoadingAvatar(false);
|
||||
},
|
||||
[setAvatarBuffer, setOldAvatarBuffer, setIsLoadingAvatar]
|
||||
[setAvatarBuffer, setOldAvatarBuffer]
|
||||
);
|
||||
|
||||
let content: JSX.Element;
|
||||
|
@ -387,10 +386,7 @@ export function ProfileEditor({
|
|||
familyName: stagedProfile.familyName,
|
||||
});
|
||||
|
||||
onProfileChanged(stagedProfile, {
|
||||
oldAvatar: oldAvatarBuffer,
|
||||
newAvatar: avatarBuffer,
|
||||
});
|
||||
onProfileChanged(stagedProfile, { keepAvatar: true });
|
||||
handleBack();
|
||||
}}
|
||||
>
|
||||
|
@ -401,9 +397,8 @@ export function ProfileEditor({
|
|||
);
|
||||
} else if (editState === EditState.Bio) {
|
||||
const shouldDisableSave =
|
||||
isLoadingAvatar ||
|
||||
(stagedProfile.aboutText === fullBio.aboutText &&
|
||||
stagedProfile.aboutEmoji === fullBio.aboutEmoji);
|
||||
stagedProfile.aboutText === fullBio.aboutText &&
|
||||
stagedProfile.aboutEmoji === fullBio.aboutEmoji;
|
||||
|
||||
const defaultBios = getDefaultBios(i18n);
|
||||
|
||||
|
@ -505,10 +500,7 @@ export function ProfileEditor({
|
|||
aboutText: stagedProfile.aboutText,
|
||||
});
|
||||
|
||||
onProfileChanged(stagedProfile, {
|
||||
oldAvatar: oldAvatarBuffer,
|
||||
newAvatar: avatarBuffer,
|
||||
});
|
||||
onProfileChanged(stagedProfile, { keepAvatar: true });
|
||||
handleBack();
|
||||
}}
|
||||
>
|
||||
|
|
|
@ -7,7 +7,7 @@ import { ConfirmationDialog } from './ConfirmationDialog';
|
|||
import type { PropsType as ProfileEditorPropsType } from './ProfileEditor';
|
||||
import { ProfileEditor, EditState } from './ProfileEditor';
|
||||
import type { ProfileDataType } from '../state/ducks/conversations';
|
||||
import type { AvatarUpdateType } from '../types/Avatar';
|
||||
import type { AvatarUpdateOptionsType } from '../types/Avatar';
|
||||
|
||||
export type PropsDataType = {
|
||||
hasError: boolean;
|
||||
|
@ -16,7 +16,7 @@ export type PropsDataType = {
|
|||
type PropsType = {
|
||||
myProfileChanged: (
|
||||
profileData: ProfileDataType,
|
||||
avatar: AvatarUpdateType
|
||||
avatarUpdateOptions: AvatarUpdateOptionsType
|
||||
) => unknown;
|
||||
toggleProfileEditor: () => unknown;
|
||||
toggleProfileEditorHasError: () => unknown;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue