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;
/**
* Update avatar
*/
"updateAvatar": string;
/**
* Remove avatar
*/
"removeAvatar": string;
/**
* Update banner
*/

View file

@ -249,30 +249,71 @@ function save() {
}
function changeAvatar(ev) {
selectFile(ev.currentTarget ?? ev.target, i18n.ts.avatar).then(async (file) => {
let originalOrCropped = file;
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,
});
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,
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) => {
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', {
avatarId: originalOrCropped.id,
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');
claimAchievement('profileFilled');
});
$i.avatarId = i.avatarId;
$i.avatarUrl = i.avatarUrl;
globalEvents.emit('requestClearPageCache');
claimAchievement('profileFilled');
});
}
}
function changeBanner(ev) {

View file

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