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;
|
"followedMessageDescriptionForLockedAccount": string;
|
||||||
|
/**
|
||||||
|
* Update avatar
|
||||||
|
*/
|
||||||
|
"updateAvatar": string;
|
||||||
|
/**
|
||||||
|
* Remove avatar
|
||||||
|
*/
|
||||||
|
"removeAvatar": string;
|
||||||
/**
|
/**
|
||||||
* Update banner
|
* Update banner
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue