upd: allow users to remove avatars

This commit is contained in:
Marie 2025-03-05 19:48:55 +01:00
parent c5440c20c6
commit daa449152d
No known key found for this signature in database
GPG key ID: 7ADF6C9CD9A28555
3 changed files with 70 additions and 19 deletions

8
locales/index.d.ts vendored
View file

@ -9064,6 +9064,14 @@ export interface Locale extends ILocale {
* *
*/ */
"followedMessageDescriptionForLockedAccount": string; "followedMessageDescriptionForLockedAccount": string;
/**
* Update avatar
*/
"updateAvatar": string;
/**
* Remove avatar
*/
"removeAvatar": string;
/** /**
* Update banner * Update banner
*/ */

View file

@ -249,30 +249,71 @@ function save() {
} }
function changeAvatar(ev) { function changeAvatar(ev) {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => { if ($i.avatarId) {
let originalOrCropped = file; os.popupMenu([{
text: i18n.ts._profile.updateAvatar,
action: async () => {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
let originalOrCropped = file;
const { canceled } = await os.confirm({ const { canceled } = await os.confirm({
type: 'question', type: 'question',
text: i18n.ts.cropImageAsk, text: i18n.ts.cropImageAsk,
okText: i18n.ts.cropYes, okText: i18n.ts.cropYes,
cancelText: i18n.ts.cropNo, cancelText: i18n.ts.cropNo,
}); });
if (!canceled) { if (!canceled) {
originalOrCropped = await os.cropImage(file, { originalOrCropped = await os.cropImage(file, {
aspectRatio: 1, aspectRatio: 1,
});
}
const i = await os.apiWithDialog('i/update', {
avatarId: originalOrCropped.id,
});
$i.avatarId = i.avatarId;
$i.avatarUrl = i.avatarUrl;
globalEvents.emit('requestClearPageCache');
});
},
}, {
text: i18n.ts._profile.removeAvatar,
action: async () => {
const i = await os.apiWithDialog('i/update', {
avatarId: null,
});
$i.avatarId = i.avatarId;
$i.avatarUrl = i.avatarUrl;
globalEvents.emit('requestClearPageCache');
},
}], ev.currentTarget ?? ev.target);
} else {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
let originalOrCropped = file;
const { canceled } = await os.confirm({
type: 'question',
text: i18n.ts.cropImageAsk,
okText: i18n.ts.cropYes,
cancelText: i18n.ts.cropNo,
}); });
}
const i = await os.apiWithDialog('i/update', { if (!canceled) {
avatarId: originalOrCropped.id, originalOrCropped = await os.cropImage(file, {
aspectRatio: 1,
});
}
const i = await os.apiWithDialog('i/update', {
avatarId: originalOrCropped.id,
});
$i.avatarId = i.avatarId;
$i.avatarUrl = i.avatarUrl;
globalEvents.emit('requestClearPageCache');
claimAchievement('profileFilled');
}); });
$i.avatarId = i.avatarId; }
$i.avatarUrl = i.avatarUrl;
globalEvents.emit('requestClearPageCache');
claimAchievement('profileFilled');
});
} }
function changeBanner(ev) { function changeBanner(ev) {

View file

@ -278,6 +278,8 @@ _widgets:
_poll: _poll:
multiple: "Multiple choices" multiple: "Multiple choices"
_profile: _profile:
updateAvatar: "Update avatar"
removeAvatar: "Remove avatar"
updateBanner: "Update banner" updateBanner: "Update banner"
removeBanner: "Remove banner" removeBanner: "Remove banner"
changeBackground: "Change background" changeBackground: "Change background"