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,6 +249,46 @@ function save() {
} }
function changeAvatar(ev) { function changeAvatar(ev) {
if ($i.avatarId) {
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({
type: 'question',
text: i18n.ts.cropImageAsk,
okText: i18n.ts.cropYes,
cancelText: i18n.ts.cropNo,
});
if (!canceled) {
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');
});
},
}, {
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) => { selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
let originalOrCropped = file; let originalOrCropped = file;
@ -274,6 +314,7 @@ function changeAvatar(ev) {
claimAchievement('profileFilled'); claimAchievement('profileFilled');
}); });
} }
}
function changeBanner(ev) { function changeBanner(ev) {
if ($i.bannerId) { if ($i.bannerId) {

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"