From 8daff4a998e9b8371f59de7af8909dd8dfc39a9e Mon Sep 17 00:00:00 2001 From: zyoshoka <107108195+zyoshoka@users.noreply.github.com> Date: Tue, 26 Dec 2023 14:19:35 +0900 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20Reactivity=E3=81=A7?= =?UTF-8?q?=E5=9E=8B=E3=82=92=E6=98=8E=E7=A4=BA=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=20(#12791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor(frontend): Reactivityで型を明示するように * fix: プロパティの参照が誤っているのを修正 * fix: 初期化の値を空配列に書き換えていた部分をnullに置き換え --- .../src/server/api/endpoints/admin/meta.ts | 4 ++ .../server/api/endpoints/federation/stats.ts | 72 +++---------------- .../backend/src/server/api/endpoints/meta.ts | 16 ++++- .../server/api/endpoints/notes/translate.ts | 4 ++ .../src/components/MkAchievements.vue | 2 +- .../frontend/src/components/MkCaptcha.vue | 2 +- packages/frontend/src/components/MkLink.vue | 2 +- .../frontend/src/components/MkMarquee.vue | 2 +- packages/frontend/src/components/MkNote.vue | 2 +- .../src/components/MkNoteDetailed.vue | 4 +- .../src/components/MkPasswordDialog.vue | 2 +- .../frontend/src/components/MkPostForm.vue | 4 +- .../frontend/src/components/MkRolePreview.vue | 3 +- packages/frontend/src/components/MkSelect.vue | 8 +-- packages/frontend/src/components/MkSignin.vue | 8 --- .../src/components/MkSignupDialog.form.vue | 6 +- .../frontend/src/components/MkSparkle.vue | 9 ++- .../MkUserAnnouncementEditDialog.vue | 2 +- .../frontend/src/components/MkWidgets.vue | 2 +- .../frontend/src/components/form/suspense.vue | 2 +- .../src/components/page/page.note.vue | 4 +- packages/frontend/src/pages/about.vue | 3 +- packages/frontend/src/pages/admin-file.vue | 5 +- packages/frontend/src/pages/admin-user.vue | 6 +- .../frontend/src/pages/admin/_header_.vue | 2 +- packages/frontend/src/pages/admin/ads.vue | 3 +- .../src/pages/admin/bot-protection.vue | 3 +- .../frontend/src/pages/admin/branding.vue | 6 +- .../src/pages/admin/email-settings.vue | 2 +- packages/frontend/src/pages/admin/files.vue | 2 +- packages/frontend/src/pages/admin/index.vue | 8 +-- packages/frontend/src/pages/admin/modlog.vue | 2 +- .../src/pages/admin/overview.federation.vue | 44 +++++++----- .../src/pages/admin/overview.instances.vue | 3 +- .../src/pages/admin/overview.moderators.vue | 3 +- .../frontend/src/pages/admin/overview.pie.vue | 9 ++- .../src/pages/admin/overview.stats.vue | 3 +- .../src/pages/admin/overview.users.vue | 3 +- .../frontend/src/pages/admin/overview.vue | 50 +++++++------ .../src/pages/admin/proxy-account.vue | 5 +- .../frontend/src/pages/admin/queue.chart.vue | 10 +-- packages/frontend/src/pages/admin/relays.vue | 5 +- .../frontend/src/pages/admin/roles.edit.vue | 5 +- .../frontend/src/pages/admin/settings.vue | 4 +- .../frontend/src/pages/antenna-timeline.vue | 3 +- packages/frontend/src/pages/api-console.vue | 2 +- .../frontend/src/pages/avatar-decorations.vue | 3 +- .../frontend/src/pages/channel-editor.vue | 9 +-- .../src/pages/custom-emojis-manager.vue | 6 +- packages/frontend/src/pages/drive.vue | 3 +- .../frontend/src/pages/emoji-edit-dialog.vue | 4 +- packages/frontend/src/pages/explore.roles.vue | 3 +- packages/frontend/src/pages/explore.users.vue | 5 +- .../frontend/src/pages/flash/flash-edit.vue | 5 +- packages/frontend/src/pages/flash/flash.vue | 5 +- packages/frontend/src/pages/gallery/edit.vue | 11 +-- packages/frontend/src/pages/gallery/post.vue | 5 +- packages/frontend/src/pages/list.vue | 5 +- .../frontend/src/pages/my-antennas/edit.vue | 3 +- .../frontend/src/pages/my-antennas/editor.vue | 11 ++- .../frontend/src/pages/my-clips/index.vue | 3 +- packages/frontend/src/pages/note.vue | 2 +- .../page-editor/els/page-editor.el.image.vue | 3 +- .../page-editor/els/page-editor.el.note.vue | 3 +- .../pages/page-editor/page-editor.blocks.vue | 5 +- .../src/pages/page-editor/page-editor.vue | 15 ++-- packages/frontend/src/pages/page.vue | 5 +- packages/frontend/src/pages/registry.keys.vue | 2 +- .../frontend/src/pages/registry.value.vue | 4 +- packages/frontend/src/pages/registry.vue | 3 +- packages/frontend/src/pages/role.vue | 5 +- packages/frontend/src/pages/search.note.vue | 2 +- .../frontend/src/pages/settings/accounts.vue | 2 +- packages/frontend/src/pages/settings/apps.vue | 2 +- .../frontend/src/pages/settings/drive.vue | 7 +- .../frontend/src/pages/settings/index.vue | 6 +- .../pages/settings/statusbar.statusbar.vue | 3 +- .../frontend/src/pages/settings/statusbar.vue | 3 +- .../src/pages/settings/theme.install.vue | 2 +- .../src/pages/settings/theme.manage.vue | 2 +- .../frontend/src/pages/user-list-timeline.vue | 3 +- .../frontend/src/pages/user/followers.vue | 2 +- .../frontend/src/pages/user/following.vue | 2 +- packages/frontend/src/pages/user/index.vue | 2 +- packages/frontend/src/pages/welcome.vue | 3 +- .../frontend/src/scripts/get-note-menu.ts | 2 +- .../frontend/src/scripts/use-chart-tooltip.ts | 8 ++- packages/frontend/src/ui/classic.vue | 6 +- packages/frontend/src/ui/visitor.vue | 3 +- .../src/widgets/WidgetActivity.calendar.vue | 7 +- .../src/widgets/WidgetActivity.chart.vue | 15 ++-- .../frontend/src/widgets/WidgetActivity.vue | 11 ++- .../frontend/src/widgets/WidgetFederation.vue | 5 +- .../src/widgets/WidgetInstanceCloud.vue | 3 +- .../frontend/src/widgets/WidgetPhotos.vue | 3 +- .../frontend/src/widgets/WidgetSlideshow.vue | 3 +- .../frontend/src/widgets/WidgetTrends.vue | 3 +- .../frontend/src/widgets/WidgetUserList.vue | 5 +- .../src/widgets/server-metric/cpu-mem.vue | 11 +-- .../src/widgets/server-metric/cpu.vue | 3 +- .../src/widgets/server-metric/disk.vue | 3 +- .../src/widgets/server-metric/index.vue | 3 +- .../src/widgets/server-metric/mem.vue | 3 +- .../src/widgets/server-metric/net.vue | 11 +-- .../misskey-js/src/autogen/apiClientJSDoc.ts | 2 +- packages/misskey-js/src/autogen/endpoint.ts | 2 +- packages/misskey-js/src/autogen/entities.ts | 2 +- packages/misskey-js/src/autogen/models.ts | 2 +- packages/misskey-js/src/autogen/types.ts | 69 +++++------------- 109 files changed, 363 insertions(+), 342 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts index 80f0dc5747..218ab42ffd 100644 --- a/packages/backend/src/server/api/endpoints/admin/meta.ts +++ b/packages/backend/src/server/api/endpoints/admin/meta.ts @@ -400,6 +400,10 @@ export const meta = { type: 'string', optional: false, nullable: true, }, + shortName: { + type: 'string', + optional: false, nullable: true, + }, objectStorageS3ForcePathStyle: { type: 'boolean', optional: false, nullable: false, diff --git a/packages/backend/src/server/api/endpoints/federation/stats.ts b/packages/backend/src/server/api/endpoints/federation/stats.ts index 6548142d41..262aa68776 100644 --- a/packages/backend/src/server/api/endpoints/federation/stats.ts +++ b/packages/backend/src/server/api/endpoints/federation/stats.ts @@ -29,37 +29,10 @@ export const meta = { optional: false, nullable: false, items: { - properties: { - id: { type: 'string' }, - firstRetrievedAt: { type: 'string' }, - host: { type: 'string' }, - usersCount: { type: 'number' }, - notesCount: { type: 'number' }, - followingCount: { type: 'number' }, - followersCount: { type: 'number' }, - isNotResponding: { type: 'boolean' }, - isSuspended: { type: 'boolean' }, - isBlocked: { type: 'boolean' }, - softwareName: { type: 'string' }, - softwareVersion: { type: 'string' }, - openRegistrations: { type: 'boolean' }, - name: { type: 'string' }, - description: { type: 'string' }, - maintainerName: { type: 'string' }, - maintainerEmail: { type: 'string' }, - isSilenced: { type: 'boolean' }, - iconUrl: { type: 'string' }, - faviconUrl: { type: 'string' }, - themeColor: { type: 'string' }, - infoUpdatedAt: { - type: 'string', - nullable: true, - }, - latestRequestReceivedAt: { - type: 'string', - nullable: true, - }, - } + type: 'object', + optional: false, + nullable: false, + ref: 'FederationInstance', }, }, otherFollowersCount: { type: 'number' }, @@ -68,42 +41,15 @@ export const meta = { optional: false, nullable: false, items: { - properties: { - id: { type: 'string' }, - firstRetrievedAt: { type: 'string' }, - host: { type: 'string' }, - usersCount: { type: 'number' }, - notesCount: { type: 'number' }, - followingCount: { type: 'number' }, - followersCount: { type: 'number' }, - isNotResponding: { type: 'boolean' }, - isSuspended: { type: 'boolean' }, - isBlocked: { type: 'boolean' }, - softwareName: { type: 'string' }, - softwareVersion: { type: 'string' }, - openRegistrations: { type: 'boolean' }, - name: { type: 'string' }, - description: { type: 'string' }, - maintainerName: { type: 'string' }, - maintainerEmail: { type: 'string' }, - isSilenced: { type: 'boolean' }, - iconUrl: { type: 'string' }, - faviconUrl: { type: 'string' }, - themeColor: { type: 'string' }, - infoUpdatedAt: { - type: 'string', - nullable: true, - }, - latestRequestReceivedAt: { - type: 'string', - nullable: true, - }, - } + type: 'object', + optional: false, + nullable: false, + ref: 'FederationInstance', }, }, otherFollowingCount: { type: 'number' }, }, - } + }, } as const; export const paramDef = { diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 8048ed3ada..9ba22f89b9 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -172,20 +172,34 @@ export const meta = { type: 'object', optional: false, nullable: false, properties: { - place: { + id: { type: 'string', optional: false, nullable: false, + format: 'id', + example: 'xxxxxxxxxx', }, url: { type: 'string', optional: false, nullable: false, format: 'url', }, + place: { + type: 'string', + optional: false, nullable: false, + }, + ratio: { + type: 'number', + optional: false, nullable: false, + }, imageUrl: { type: 'string', optional: false, nullable: false, format: 'url', }, + dayOfWeek: { + type: 'integer', + optional: false, nullable: false, + }, }, }, }, diff --git a/packages/backend/src/server/api/endpoints/notes/translate.ts b/packages/backend/src/server/api/endpoints/notes/translate.ts index a1561c944c..d46bd69795 100644 --- a/packages/backend/src/server/api/endpoints/notes/translate.ts +++ b/packages/backend/src/server/api/endpoints/notes/translate.ts @@ -21,6 +21,10 @@ export const meta = { res: { type: 'object', optional: false, nullable: false, + properties: { + sourceLang: { type: 'string' }, + text: { type: 'string' }, + }, }, errors: { diff --git a/packages/frontend/src/components/MkAchievements.vue b/packages/frontend/src/components/MkAchievements.vue index 40f9ad4057..cdd9cb87b1 100644 --- a/packages/frontend/src/components/MkAchievements.vue +++ b/packages/frontend/src/components/MkAchievements.vue @@ -67,7 +67,7 @@ const props = withDefaults(defineProps<{ withDescription: true, }); -const achievements = ref(); +const achievements = ref(null); const lockedAchievements = computed(() => ACHIEVEMENT_TYPES.filter(x => !(achievements.value ?? []).some(a => a.name === x))); function fetch() { diff --git a/packages/frontend/src/components/MkCaptcha.vue b/packages/frontend/src/components/MkCaptcha.vue index 14e59acad2..40bca11e64 100644 --- a/packages/frontend/src/components/MkCaptcha.vue +++ b/packages/frontend/src/components/MkCaptcha.vue @@ -26,7 +26,7 @@ export type Captcha = { getResponse(id: string): string; }; -type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile'; +export type CaptchaProvider = 'hcaptcha' | 'recaptcha' | 'turnstile'; type CaptchaContainer = { readonly [_ in CaptchaProvider]?: Captcha; diff --git a/packages/frontend/src/components/MkLink.vue b/packages/frontend/src/components/MkLink.vue index e16307c762..bda683002d 100644 --- a/packages/frontend/src/components/MkLink.vue +++ b/packages/frontend/src/components/MkLink.vue @@ -29,7 +29,7 @@ const self = props.url.startsWith(local); const attr = self ? 'to' : 'href'; const target = self ? null : '_blank'; -const el = ref(); +const el = ref(); useTooltip(el, (showing) => { os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), { diff --git a/packages/frontend/src/components/MkMarquee.vue b/packages/frontend/src/components/MkMarquee.vue index f9d0573227..145b60c8e7 100644 --- a/packages/frontend/src/components/MkMarquee.vue +++ b/packages/frontend/src/components/MkMarquee.vue @@ -27,7 +27,7 @@ export default { }, }, setup(props) { - const contentEl = ref(); + const contentEl = ref(); function calc() { const eachLength = contentEl.value.offsetWidth / props.repeat; diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index cdd2cccb2e..8a3b4cef48 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -289,7 +289,7 @@ const isDeleted = ref(false); const renoted = ref(false); const muted = ref(checkMute(appearNote.value, $i?.mutedWords)); const hardMuted = ref(props.withHardMute && checkMute(appearNote.value, $i?.hardMutedWords)); -const translation = ref(null); +const translation = ref(null); const translating = ref(false); const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.value.user.instance); const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i.id)); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index a793a85ff9..e287890e2c 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -309,7 +309,7 @@ const showContent = ref(defaultStore.state.uncollapseCW); const isDeleted = ref(false); const renoted = ref(false); const muted = ref($i ? checkWordMute(appearNote.value, $i, $i.mutedWords) : false); -const translation = ref(null); +const translation = ref(null); const translating = ref(false); const parsed = appearNote.value.text ? mfm.parse(appearNote.value.text) : null; const urls = parsed ? extractUrlFromMfm(parsed).filter(u => u !== renoteUrl && u !== renoteUri) : null; @@ -353,7 +353,7 @@ provide('react', (reaction: string) => { }); const tab = ref('replies'); -const reactionTabType = ref(null); +const reactionTabType = ref(null); const renotesPagination = computed(() => ({ endpoint: 'notes/renotes', diff --git a/packages/frontend/src/components/MkPasswordDialog.vue b/packages/frontend/src/components/MkPasswordDialog.vue index 711c54c7f1..85dd402730 100644 --- a/packages/frontend/src/components/MkPasswordDialog.vue +++ b/packages/frontend/src/components/MkPasswordDialog.vue @@ -52,7 +52,7 @@ const emit = defineEmits<{ const dialog = shallowRef>(); const passwordInput = shallowRef>(); const password = ref(''); -const token = ref(null); +const token = ref(null); function onClose() { emit('cancelled'); diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index b26ce2932a..8838da15a9 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -187,14 +187,14 @@ watch(showPreview, () => defaultStore.set('showPreview', showPreview.value)); const cw = ref(props.initialCw ?? null); const localOnly = ref(props.initialLocalOnly ?? defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly); const visibility = ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility) as typeof Misskey.noteVisibilities[number]); -const visibleUsers = ref([]); +const visibleUsers = ref([]); if (props.initialVisibleUsers) { props.initialVisibleUsers.forEach(pushVisibleUser); } const reactionAcceptance = ref(defaultStore.state.reactionAcceptance); const autocomplete = ref(null); const draghover = ref(false); -const quoteId = ref(null); +const quoteId = ref(null); const hasNotSpecifiedMentions = ref(false); const recentHashtags = ref(JSON.parse(miLocalStorage.getItem('hashtags') ?? '[]')); const imeText = ref(''); diff --git a/packages/frontend/src/components/MkRolePreview.vue b/packages/frontend/src/components/MkRolePreview.vue index 0e8ce35609..bd1767155b 100644 --- a/packages/frontend/src/components/MkRolePreview.vue +++ b/packages/frontend/src/components/MkRolePreview.vue @@ -28,10 +28,11 @@ SPDX-License-Identifier: AGPL-3.0-only