From 5b26ad5953b2c877ab796f64bd52abca8b956a4a Mon Sep 17 00:00:00 2001 From: taiy <53635909+taiyme@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:56:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E3=83=87=E3=82=B3=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=82=92=E4=BB=98=E3=81=91=E3=82=8B?= =?UTF-8?q?=E3=81=A8MkAvatar=E3=81=A7=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B=E5=95=8F=E9=A1=8C=20(#300)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/avatar-decoration.dialog.vue | 36 +++++++--------- .../src/pages/settings/avatar-decoration.vue | 42 ++++++++++--------- 2 files changed, 38 insertions(+), 40 deletions(-) diff --git a/packages/frontend/src/pages/settings/avatar-decoration.dialog.vue b/packages/frontend/src/pages/settings/avatar-decoration.dialog.vue index 853e536ea30b..2d186cf132fd 100644 --- a/packages/frontend/src/pages/settings/avatar-decoration.dialog.vue +++ b/packages/frontend/src/pages/settings/avatar-decoration.dialog.vue @@ -46,6 +46,7 @@ SPDX-License-Identifier: AGPL-3.0-only diff --git a/packages/frontend/src/pages/settings/avatar-decoration.vue b/packages/frontend/src/pages/settings/avatar-decoration.vue index 3233817551c1..c81b75f19504 100644 --- a/packages/frontend/src/pages/settings/avatar-decoration.vue +++ b/packages/frontend/src/pages/settings/avatar-decoration.vue @@ -19,13 +19,14 @@ SPDX-License-Identifier: AGPL-3.0-only
@@ -61,55 +62,58 @@ import { signinRequired } from '@/account.js'; import MkInfo from '@/components/MkInfo.vue'; import { definePageMetadata } from '@/scripts/page-metadata.js'; +type AvatarDecoration = Misskey.entities.GetAvatarDecorationsResponse[number]; +type AvatarDecorationWithPosition = Omit; + const $i = signinRequired(); const loading = ref(true); -const avatarDecorations = ref([]); +const avatarDecorations = ref([]); misskeyApi('get-avatar-decorations').then(_avatarDecorations => { avatarDecorations.value = _avatarDecorations; loading.value = false; }); -function openDecoration(avatarDecoration, index?: number) { +function openDecoration(avatarDecoration: AvatarDecoration, index?: number) { const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration.dialog.vue')), { decoration: avatarDecoration, - usingIndex: index, + usingIndex: index ?? null, }, { - 'attach': async (payload) => { + 'attach': async (payload: AvatarDecorationWithPosition) => { const decoration = { + ...payload, id: avatarDecoration.id, - angle: payload.angle, - flipH: payload.flipH, - offsetX: payload.offsetX, - offsetY: payload.offsetY, - }; + url: avatarDecoration.url, + } as const satisfies AvatarDecorationWithPosition & Pick; const update = [...$i.avatarDecorations, decoration]; await os.apiWithDialog('i/update', { avatarDecorations: update, }); $i.avatarDecorations = update; }, - 'update': async (payload) => { + 'update': async (payload: AvatarDecorationWithPosition) => { + if (index == null) return; const decoration = { + ...payload, id: avatarDecoration.id, - angle: payload.angle, - flipH: payload.flipH, - offsetX: payload.offsetX, - offsetY: payload.offsetY, - }; + url: avatarDecoration.url, + } as const satisfies AvatarDecorationWithPosition & Pick; const update = [...$i.avatarDecorations]; update[index] = decoration; await os.apiWithDialog('i/update', { - avatarDecorations: update, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + avatarDecorations: update.map(({ url, ...d }) => d), }); $i.avatarDecorations = update; }, 'detach': async () => { + if (index == null) return; const update = [...$i.avatarDecorations]; update.splice(index, 1); await os.apiWithDialog('i/update', { - avatarDecorations: update, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + avatarDecorations: update.map(({ url, ...d }) => d), }); $i.avatarDecorations = update; },