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); setNewAvatarObjectUrl(null);
setOldAvatarPath(null); setOldAvatarPath(null);
setLoading(false); setLoading(false);
closeDialog();
}; };
return ( return (
@ -115,14 +116,14 @@ export const DisplayPictureModal = (props: DisplayPictureModalProps) => {
text={window.i18n('upload')} text={window.i18n('upload')}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
onClick={handleUpload} onClick={handleUpload}
disabled={_newAvatarObjectUrl === newAvatarObjectUrl} disabled={loading || _newAvatarObjectUrl === newAvatarObjectUrl}
/> />
<SessionButton <SessionButton
text={window.i18n('remove')} text={window.i18n('remove')}
buttonColor={SessionButtonColor.Danger} buttonColor={SessionButtonColor.Danger}
buttonType={SessionButtonType.Simple} buttonType={SessionButtonType.Simple}
onClick={handleRemove} onClick={handleRemove}
disabled={!oldAvatarPath} disabled={loading || !oldAvatarPath}
/> />
</div> </div>
</SessionWrapperModal> </SessionWrapperModal>

View file

@ -490,23 +490,23 @@ export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) {
/** /**
* This function can be used for clearing our avatar. * 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()); const ourConvo = getConversationController().get(UserUtils.getOurPubKeyStrFromCache());
if (!ourConvo) { if (!ourConvo) {
window.log.warn('ourConvo not found... This is not a valid case'); window.log.warn('ourConvo not found... This is not a valid case');
return; return;
} }
// TODO check if defined first
ourConvo.set('avatarPointer', undefined); ourConvo.set('avatarPointer', undefined);
ourConvo.set('avatarInProfile', undefined); ourConvo.set('avatarInProfile', undefined);
ourConvo.set('profileKey', undefined); ourConvo.set('profileKey', undefined);
await ourConvo.commit();
await setLastProfileUpdateTimestamp(Date.now()); 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) { export async function replyToMessage(messageId: string) {