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, },