feat: 下書きを自動保存するかどうかを設定できるように

This commit is contained in:
yukineko 2024-04-18 19:17:49 +09:00 committed by mattyatea
parent d564bd73bc
commit ab98d149a5
3 changed files with 36 additions and 1 deletions

View File

@ -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,
});
</script>

View File

@ -50,6 +50,7 @@ function onPosted() {
}
function onModalClosed() {
form.value?.closed();
emit('closed');
}
</script>

View File

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