From e6db7b9fa74680df94cf3336d7d2dd527c961b63 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 18 Jul 2023 19:17:17 +0900 Subject: feat(frontend): Renote時に公開範囲のデフォルト設定が適用されるように (#11240) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use saved visibility on renote * chore: use saved localOnly on renote * docs: add comment about why smallerVisibility accepts string * docs(changelog): add Renote時に公開範囲のデフォルト設定が適用されるように --------- Co-authored-by: syuilo --- packages/frontend/src/components/MkNote.vue | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'packages/frontend/src/components/MkNote.vue') diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 8fc5e0de5b..7a7406931b 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -259,6 +259,17 @@ useTooltip(renoteButton, async (showing) => { }, {}, 'closed'); }); +type Visibility = 'public' | 'home' | 'followers' | 'specified'; + +// defaultStore.state.visibilityがstringなためstringも受け付けている +function smallerVisibility(a: Visibility | string, b: Visibility | string): Visibility { + if (a === 'specified' || b === 'specified') return 'specified'; + if (a === 'followers' || b === 'followers') return 'followers'; + if (a === 'home' || b === 'home') return 'home'; + // if (a === 'public' || b === 'public') + return 'public'; +} + function renote(viaKeyboard = false) { pleaseLogin(); showMovedDialog(); @@ -309,7 +320,12 @@ function renote(viaKeyboard = false) { os.popup(MkRippleEffect, { x, y }, {}, 'end'); } + const configuredVisibility = defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility; + const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; + os.api('notes/create', { + localOnly, + visibility: smallerVisibility(appearNote.visibility, configuredVisibility), renoteId: appearNote.id, }).then(() => { os.toast(i18n.ts.renoted); -- cgit v1.2.3-freya