From ab98d149a5b3816ce636b55adc2752b56c799b29 Mon Sep 17 00:00:00 2001 From: yukineko <27853966+hideki0403@users.noreply.github.com> Date: Thu, 18 Apr 2024 19:17:49 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=8B=E6=9B=B8=E3=81=8D=E3=82=92?= =?UTF-8?q?=E8=87=AA=E5=8B=95=E4=BF=9D=E5=AD=98=E3=81=99=E3=82=8B=E3=81=8B?= =?UTF-8?q?=E3=81=A9=E3=81=86=E3=81=8B=E3=82=92=E8=A8=AD=E5=AE=9A=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/components/MkPostForm.vue | 15 +++++++++++++ .../src/components/MkPostFormDialog.vue | 1 + packages/frontend/src/store.ts | 21 ++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 2d8a341d50..e2f1ab6f3b 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -706,6 +706,8 @@ function onDrop(ev: DragEvent): void { function saveDraft(auto = true) { if (props.instant || props.mock) return; + if (auto && defaultStore.state.draftSavingBehavior !== 'auto') return; + if (!auto) { // 手動での保存の場合は自動保存したものを削除した上で保存 noteDrafts.remove(draftType.value, $i.id, 'default', draftAuxId.value as string); @@ -952,6 +954,18 @@ function cancel() { emit('cancel'); } +async function closed() { + if (defaultStore.state.draftSavingBehavior === 'manual' && text.value !== '') { + os.confirm({ + type: 'question', + text: i18n.ts.saveConfirm, + }).then(({ canceled }) => { + if (canceled) return; + saveDraft(false); + }); + } +} + function insertMention() { os.selectUser({ localOnly: localOnly.value, includeSelf: true }).then(user => { insertTextAtCursor(textareaEl.value, '@' + Misskey.acct.toString(user) + ' '); @@ -1109,6 +1123,7 @@ onMounted(() => { defineExpose({ clear, + closed, }); diff --git a/packages/frontend/src/components/MkPostFormDialog.vue b/packages/frontend/src/components/MkPostFormDialog.vue index d3de1af75e..075635d67e 100644 --- a/packages/frontend/src/components/MkPostFormDialog.vue +++ b/packages/frontend/src/components/MkPostFormDialog.vue @@ -50,6 +50,7 @@ function onPosted() { } function onModalClosed() { + form.value?.closed(); emit('closed'); } diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts index ecd243f681..c20c945aef 100644 --- a/packages/frontend/src/store.ts +++ b/packages/frontend/src/store.ts @@ -101,8 +101,27 @@ export const defaultStore = markRaw(new Storage('base', { defaultHomeNoteLocalOnly: { where: 'account', default: false, + }, defaultFollowersNoteLocalOnly: { + where: 'account', + default: false, }, - defaultFollowersNoteLocalOnly: { + draftSavingBehavior: { + where: 'account', + default: 'auto' as 'auto' | 'manual', + }, + rememberNoteVisibility: { + where: 'account', + default: false, + }, + rememberReactionAcceptance: { + where: 'account', + default: false, + }, + defaultNoteVisibility: { + where: 'account', + default: 'home', + }, + defaultNoteLocalOnly: { where: 'account', default: false, },