Give the option to auto save drafts
This commit is contained in:
parent
8a58de5c9f
commit
86f6fbeb46
6 changed files with 55 additions and 8 deletions
|
|
@ -324,12 +324,24 @@ const PostStatusForm = {
|
|||
|
||||
return false
|
||||
},
|
||||
// debouncedSaveDraft () {
|
||||
// return debounce(this.saveDraft, 3000)
|
||||
// },
|
||||
debouncedMaybeAutoSaveDraft () {
|
||||
return debounce(this.maybeAutoSaveDraft, 3000)
|
||||
},
|
||||
pollFormVisible () {
|
||||
return this.newStatus.hasPoll
|
||||
},
|
||||
shouldAutoSaveDraft () {
|
||||
return this.$store.getters.mergedConfig.autoSaveDraft
|
||||
},
|
||||
autoSaveState () {
|
||||
if (this.savable) {
|
||||
return this.$t('post_status.auto_save_saving')
|
||||
} else if (this.newStatus.id) {
|
||||
return this.$t('post_status.auto_save_saved')
|
||||
} else {
|
||||
return this.$t('post_status.auto_save_nothing_new')
|
||||
}
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState({
|
||||
mobileLayout: state => state.interface.mobileLayout
|
||||
|
|
@ -344,13 +356,13 @@ const PostStatusForm = {
|
|||
}
|
||||
},
|
||||
beforeUnmount () {
|
||||
// this.saveDraft()
|
||||
this.maybeAutoSaveDraft()
|
||||
},
|
||||
methods: {
|
||||
statusChanged () {
|
||||
this.autoPreview()
|
||||
this.updateIdempotencyKey()
|
||||
// this.debouncedSaveDraft()
|
||||
this.debouncedMaybeAutoSaveDraft()
|
||||
this.savable = true
|
||||
this.saveInhibited = false
|
||||
},
|
||||
|
|
@ -722,12 +734,17 @@ const PostStatusForm = {
|
|||
.then(id => {
|
||||
if (this.newStatus.id !== id) {
|
||||
this.newStatus.id = id
|
||||
this.savable = false
|
||||
}
|
||||
this.savable = false
|
||||
})
|
||||
}
|
||||
return Promise.resolve()
|
||||
},
|
||||
maybeAutoSaveDraft () {
|
||||
if (this.shouldAutoSaveDraft) {
|
||||
this.saveDraft()
|
||||
}
|
||||
},
|
||||
abandonDraft () {
|
||||
return this.$store.dispatch('abandonDraft', { id: this.newStatus.id })
|
||||
},
|
||||
|
|
|
|||
|
|
@ -297,6 +297,18 @@
|
|||
<FAIcon icon="poll-h" />
|
||||
</button>
|
||||
</div>
|
||||
<span
|
||||
v-if="shouldAutoSaveDraft"
|
||||
class="auto-save-status"
|
||||
>
|
||||
{{ autoSaveState }}
|
||||
</span>
|
||||
<button
|
||||
v-else
|
||||
class="btn button-default"
|
||||
>
|
||||
{{ $t('post_status.save_to_drafts_button') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="posting"
|
||||
disabled
|
||||
|
|
@ -612,5 +624,9 @@
|
|||
border-radius: var(--roundness);
|
||||
border: 2px dashed var(--text);
|
||||
}
|
||||
|
||||
.auto-save-status {
|
||||
align-self: center;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -453,6 +453,13 @@
|
|||
{{ $t('settings.autocomplete_select_first') }}
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
<li>
|
||||
<BooleanSetting
|
||||
path="autoSaveDraft"
|
||||
>
|
||||
{{ $t('settings.auto_save_draft') }}
|
||||
</BooleanSetting>
|
||||
</li>
|
||||
<li>
|
||||
<ChoiceSetting
|
||||
id="unsavedPostAction"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue