upd: allow users to remove avatars
This commit is contained in:
parent
c5440c20c6
commit
daa449152d
3 changed files with 70 additions and 19 deletions
8
locales/index.d.ts
vendored
8
locales/index.d.ts
vendored
|
@ -9064,6 +9064,14 @@ export interface Locale extends ILocale {
|
|||
* フォローを承認制にしている場合、フォローリクエストを許可した時に表示されます。
|
||||
*/
|
||||
"followedMessageDescriptionForLockedAccount": string;
|
||||
/**
|
||||
* Update avatar
|
||||
*/
|
||||
"updateAvatar": string;
|
||||
/**
|
||||
* Remove avatar
|
||||
*/
|
||||
"removeAvatar": string;
|
||||
/**
|
||||
* Update banner
|
||||
*/
|
||||
|
|
|
@ -249,6 +249,46 @@ function save() {
|
|||
}
|
||||
|
||||
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) => {
|
||||
let originalOrCropped = file;
|
||||
|
||||
|
@ -273,6 +313,7 @@ function changeAvatar(ev) {
|
|||
globalEvents.emit('requestClearPageCache');
|
||||
claimAchievement('profileFilled');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function changeBanner(ev) {
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue