From 9f66f229537915f47da8e6e08e92a78be390f454 Mon Sep 17 00:00:00 2001 From: taiy <53635909+taiyme@users.noreply.github.com> Date: Wed, 1 May 2024 15:29:38 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E9=80=A3=E5=90=88=E3=81=AA?= =?UTF-8?q?=E3=81=97=E3=81=AE=E7=8A=B6=E6=85=8B=E3=81=AE=E8=AA=AD=E3=81=BF?= =?UTF-8?q?=E6=9B=B8=E3=81=8D=E3=81=8C=E3=81=A7=E3=81=8D=E3=81=AA=E3=81=84?= =?UTF-8?q?=E5=95=8F=E9=A1=8C=20(#13777)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 連合なしの状態の読み書きができない問題 * update changelog * fix types: https://github.com/misskey-dev/misskey/pull/13777#discussion_r1585901601 --- CHANGELOG.md | 1 + packages/frontend/src/components/MkPostForm.vue | 8 ++++++-- packages/frontend/src/components/MkPostFormDialog.vue | 6 ++++-- packages/frontend/src/scripts/get-note-menu.ts | 5 ++--- packages/frontend/src/store.ts | 4 ++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68015596bd..4b65550daf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ - Fix: ページのOGP URLが間違っているのを修正 - Fix: リバーシの対局を正しく共有できないことがある問題を修正 - Fix: 通知をグループ化している際に、人数が正常に表示されないことがある問題を修正 +- Fix: 連合なしの状態の読み書きができない問題を修正 ### Server - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index d7efca9de9..7dbc127298 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -156,6 +156,7 @@ const props = withDefaults(defineProps<{ initialVisibleUsers: () => [], autofocus: true, mock: false, + initialLocalOnly: undefined, }); provide('mock', props.mock); @@ -185,8 +186,8 @@ watch(showPreview, () => defaultStore.set('showPreview', showPreview.value)); const showAddMfmFunction = ref(defaultStore.state.enableQuickAddMfmFunction); watch(showAddMfmFunction, () => defaultStore.set('enableQuickAddMfmFunction', showAddMfmFunction.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 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)); const visibleUsers = ref([]); if (props.initialVisibleUsers) { props.initialVisibleUsers.forEach(pushVisibleUser); @@ -518,6 +519,9 @@ async function toggleLocalOnly() { } localOnly.value = !localOnly.value; + if (defaultStore.state.rememberNoteVisibility) { + defaultStore.set('localOnly', localOnly.value); + } } async function toggleReactionAcceptance() { diff --git a/packages/frontend/src/components/MkPostFormDialog.vue b/packages/frontend/src/components/MkPostFormDialog.vue index 6331dfed29..ac37cb31bc 100644 --- a/packages/frontend/src/components/MkPostFormDialog.vue +++ b/packages/frontend/src/components/MkPostFormDialog.vue @@ -15,7 +15,7 @@ import * as Misskey from 'misskey-js'; import MkModal from '@/components/MkModal.vue'; import MkPostForm from '@/components/MkPostForm.vue'; -const props = defineProps<{ +const props = withDefaults(defineProps<{ reply?: Misskey.entities.Note; renote?: Misskey.entities.Note; channel?: any; // TODO @@ -31,7 +31,9 @@ const props = defineProps<{ instant?: boolean; fixed?: boolean; autofocus?: boolean; -}>(); +}>(), { + initialLocalOnly: undefined, +}); const emit = defineEmits<{ (ev: 'closed'): void; diff --git a/packages/frontend/src/scripts/get-note-menu.ts b/packages/frontend/src/scripts/get-note-menu.ts index 87921bc67f..2cd21c1edc 100644 --- a/packages/frontend/src/scripts/get-note-menu.ts +++ b/packages/frontend/src/scripts/get-note-menu.ts @@ -492,10 +492,9 @@ export function getNoteMenu(props: { }; } -type Visibility = 'public' | 'home' | 'followers' | 'specified'; +type Visibility = (typeof Misskey.noteVisibilities)[number]; -// defaultStore.state.visibilityがstringなためstringも受け付けている -function smallerVisibility(a: Visibility | string, b: Visibility | string): Visibility { +function smallerVisibility(a: Visibility, b: Visibility): Visibility { if (a === 'specified' || b === 'specified') return 'specified'; if (a === 'followers' || b === 'followers') return 'followers'; if (a === 'home' || b === 'home') return 'home'; diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index e6a348b79f..e8eb5a1ed7 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -94,7 +94,7 @@ export const defaultStore = markRaw(new Storage('base', { }, defaultNoteVisibility: { where: 'account', - default: 'public', + default: 'public' as (typeof Misskey.noteVisibilities)[number], }, defaultNoteLocalOnly: { where: 'account', @@ -150,7 +150,7 @@ export const defaultStore = markRaw(new Storage('base', { }, visibility: { where: 'deviceAccount', - default: 'public' as 'public' | 'home' | 'followers' | 'specified', + default: 'public' as (typeof Misskey.noteVisibilities)[number], }, localOnly: { where: 'deviceAccount',