feat: desktop now supports avatar being removed via sync configuration message

disabled buttons while loading
This commit is contained in:
William Grant 2023-05-23 15:36:39 +10:00
parent 84d3d5b1b4
commit b59f1bf445
2 changed files with 8 additions and 7 deletions

View file

@ -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}
/>
<SessionButton
text={window.i18n('remove')}
buttonColor={SessionButtonColor.Danger}
buttonType={SessionButtonType.Simple}
onClick={handleRemove}
disabled={!oldAvatarPath}
disabled={loading || !oldAvatarPath}
/>
</div>
</SessionWrapperModal>

View file

@ -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) {