Skip to content

Commit 02d5954

Browse files
committed
Fix Avatar Upload Issue
1 parent dacd99a commit 02d5954

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

grep

Whitespace-only changes.

src/main.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,7 @@ const domProfileStatus = document.getElementById('profile-status');
856856
// Note: these are 'let' due to needing to use `.replaceWith` when hot-swapping profile elements
857857
let fProfileEditMode = false;
858858
let objProfileEditSnapshot = {};
859+
let strPendingProfileAvatarPath = null;
859860
const domProfileEditBtn = document.getElementById('profile-edit-btn');
860861
const domProfileEditBar = document.getElementById('profile-edit-bar');
861862
const domProfileEditCancelBtn = document.getElementById('profile-edit-cancel-btn');
@@ -7856,6 +7857,7 @@ function enterProfileEditMode() {
78567857
filters: [{ name: 'Image', extensions: ['png', 'jpeg', 'jpg', 'gif', 'webp'] }]
78577858
});
78587859
if (!file) return;
7860+
strPendingProfileAvatarPath = file;
78597861
domProfileAvatar.src = convertFileSrc(file);
78607862
};
78617863

@@ -7937,6 +7939,23 @@ function exitProfileEditMode(fCancel = false) {
79377939
if (statusChanged) {
79387940
invoke('update_status', { status: newStatus }).catch(e => popupConfirm('Status Update Failed!', escapeHtml(String(e)), true, '', 'vector_warning.svg'));
79397941
}
7942+
if (strPendingProfileAvatarPath) {
7943+
invoke('upload_avatar', { filepath: strPendingProfileAvatarPath, uploadType: 'avatar' })
7944+
.then(avatarUrl => {
7945+
if (avatarUrl) {
7946+
invoke('update_profile', {
7947+
name: '',
7948+
avatar: avatarUrl,
7949+
banner: '',
7950+
about: '',
7951+
}).then(ok => {
7952+
if (!ok) popupConfirm('Avatar Update Failed!', 'Failed to broadcast avatar update to the network.', true, '', 'vector_warning.svg');
7953+
}).catch(e => popupConfirm('Avatar Update Failed!', escapeHtml(String(e)), true, '', 'vector_warning.svg'));
7954+
}
7955+
})
7956+
.catch(e => popupConfirm('Avatar Upload Failed!', escapeHtml(String(e)), true, '', 'vector_warning.svg'));
7957+
strPendingProfileAvatarPath = null;
7958+
}
79407959

79417960
showToast('Profile Saved');
79427961
}

0 commit comments

Comments
 (0)