diff --git a/ts/components/dialog/DisplayPictureModal.tsx b/ts/components/dialog/DisplayPictureModal.tsx index 96feefc74..ab891b7d0 100644 --- a/ts/components/dialog/DisplayPictureModal.tsx +++ b/ts/components/dialog/DisplayPictureModal.tsx @@ -79,6 +79,7 @@ export const DisplayPictureModal = (props: DisplayPictureModalProps) => { setNewAvatarObjectUrl(null); setOldAvatarPath(null); setLoading(false); + closeDialog(); }; return ( @@ -115,14 +116,14 @@ export const DisplayPictureModal = (props: DisplayPictureModalProps) => { text={window.i18n('upload')} buttonType={SessionButtonType.Simple} onClick={handleUpload} - disabled={_newAvatarObjectUrl === newAvatarObjectUrl} + disabled={loading || _newAvatarObjectUrl === newAvatarObjectUrl} /> diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index c85185766..bbd0044e4 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -490,23 +490,23 @@ export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) { /** * This function can be used for clearing our avatar. */ -export async function clearOurAvatar() { +export async function clearOurAvatar(commit: boolean = true) { const ourConvo = getConversationController().get(UserUtils.getOurPubKeyStrFromCache()); if (!ourConvo) { window.log.warn('ourConvo not found... This is not a valid case'); return; } - // TODO check if defined first ourConvo.set('avatarPointer', undefined); ourConvo.set('avatarInProfile', undefined); ourConvo.set('profileKey', undefined); - await ourConvo.commit(); await setLastProfileUpdateTimestamp(Date.now()); - await SyncUtils.forceSyncConfigurationNowIfNeeded(true); - // TODO send messages to opengroups to clear avatar from there + if (commit) { + await ourConvo.commit(); + await SyncUtils.forceSyncConfigurationNowIfNeeded(true); + } } export async function replyToMessage(messageId: string) {