Give the option to auto save drafts
This commit is contained in:
parent
8a58de5c9f
commit
86f6fbeb46
|
@ -324,12 +324,24 @@ const PostStatusForm = {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
// debouncedSaveDraft () {
|
debouncedMaybeAutoSaveDraft () {
|
||||||
// return debounce(this.saveDraft, 3000)
|
return debounce(this.maybeAutoSaveDraft, 3000)
|
||||||
// },
|
},
|
||||||
pollFormVisible () {
|
pollFormVisible () {
|
||||||
return this.newStatus.hasPoll
|
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']),
|
...mapGetters(['mergedConfig']),
|
||||||
...mapState({
|
...mapState({
|
||||||
mobileLayout: state => state.interface.mobileLayout
|
mobileLayout: state => state.interface.mobileLayout
|
||||||
|
@ -344,13 +356,13 @@ const PostStatusForm = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
// this.saveDraft()
|
this.maybeAutoSaveDraft()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
statusChanged () {
|
statusChanged () {
|
||||||
this.autoPreview()
|
this.autoPreview()
|
||||||
this.updateIdempotencyKey()
|
this.updateIdempotencyKey()
|
||||||
// this.debouncedSaveDraft()
|
this.debouncedMaybeAutoSaveDraft()
|
||||||
this.savable = true
|
this.savable = true
|
||||||
this.saveInhibited = false
|
this.saveInhibited = false
|
||||||
},
|
},
|
||||||
|
@ -722,12 +734,17 @@ const PostStatusForm = {
|
||||||
.then(id => {
|
.then(id => {
|
||||||
if (this.newStatus.id !== id) {
|
if (this.newStatus.id !== id) {
|
||||||
this.newStatus.id = id
|
this.newStatus.id = id
|
||||||
this.savable = false
|
|
||||||
}
|
}
|
||||||
|
this.savable = false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
},
|
},
|
||||||
|
maybeAutoSaveDraft () {
|
||||||
|
if (this.shouldAutoSaveDraft) {
|
||||||
|
this.saveDraft()
|
||||||
|
}
|
||||||
|
},
|
||||||
abandonDraft () {
|
abandonDraft () {
|
||||||
return this.$store.dispatch('abandonDraft', { id: this.newStatus.id })
|
return this.$store.dispatch('abandonDraft', { id: this.newStatus.id })
|
||||||
},
|
},
|
||||||
|
|
|
@ -297,6 +297,18 @@
|
||||||
<FAIcon icon="poll-h" />
|
<FAIcon icon="poll-h" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</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
|
<button
|
||||||
v-if="posting"
|
v-if="posting"
|
||||||
disabled
|
disabled
|
||||||
|
@ -612,5 +624,9 @@
|
||||||
border-radius: var(--roundness);
|
border-radius: var(--roundness);
|
||||||
border: 2px dashed var(--text);
|
border: 2px dashed var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.auto-save-status {
|
||||||
|
align-self: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -453,6 +453,13 @@
|
||||||
{{ $t('settings.autocomplete_select_first') }}
|
{{ $t('settings.autocomplete_select_first') }}
|
||||||
</BooleanSetting>
|
</BooleanSetting>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<BooleanSetting
|
||||||
|
path="autoSaveDraft"
|
||||||
|
>
|
||||||
|
{{ $t('settings.auto_save_draft') }}
|
||||||
|
</BooleanSetting>
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<ChoiceSetting
|
<ChoiceSetting
|
||||||
id="unsavedPostAction"
|
id="unsavedPostAction"
|
||||||
|
|
|
@ -313,7 +313,11 @@
|
||||||
"close_confirm": "What do you want to do with your current writing?",
|
"close_confirm": "What do you want to do with your current writing?",
|
||||||
"close_confirm_save_button": "Save",
|
"close_confirm_save_button": "Save",
|
||||||
"close_confirm_discard_button": "Discard",
|
"close_confirm_discard_button": "Discard",
|
||||||
"close_confirm_continue_composing_button": "Continue composing"
|
"close_confirm_continue_composing_button": "Continue composing",
|
||||||
|
"auto_save_nothing_new": "Nothing new to save.",
|
||||||
|
"auto_save_saved": "Saved.",
|
||||||
|
"auto_save_saving": "Saving...",
|
||||||
|
"save_to_drafts_button": "Save to drafts"
|
||||||
},
|
},
|
||||||
"registration": {
|
"registration": {
|
||||||
"bio_optional": "Bio (optional)",
|
"bio_optional": "Bio (optional)",
|
||||||
|
@ -514,6 +518,7 @@
|
||||||
"unsaved_post_action_save": "Save it to drafts",
|
"unsaved_post_action_save": "Save it to drafts",
|
||||||
"unsaved_post_action_discard": "Discard it",
|
"unsaved_post_action_discard": "Discard it",
|
||||||
"unsaved_post_action_confirm": "Ask every time",
|
"unsaved_post_action_confirm": "Ask every time",
|
||||||
|
"auto_save_draft": "Save drafts as you compose",
|
||||||
"emoji_reactions_on_timeline": "Show emoji reactions on timeline",
|
"emoji_reactions_on_timeline": "Show emoji reactions on timeline",
|
||||||
"emoji_reactions_scale": "Reactions scale factor",
|
"emoji_reactions_scale": "Reactions scale factor",
|
||||||
"export_theme": "Save preset",
|
"export_theme": "Save preset",
|
||||||
|
|
|
@ -182,7 +182,8 @@ export const defaultState = {
|
||||||
closingDrawerMarksAsSeen: undefined, // instance default
|
closingDrawerMarksAsSeen: undefined, // instance default
|
||||||
unseenAtTop: undefined, // instance default
|
unseenAtTop: undefined, // instance default
|
||||||
ignoreInactionableSeen: undefined, // instance default
|
ignoreInactionableSeen: undefined, // instance default
|
||||||
unsavedPostAction: undefined // instance default
|
unsavedPostAction: undefined, // instance default
|
||||||
|
autoSaveDraft: undefined // instance default
|
||||||
}
|
}
|
||||||
|
|
||||||
// caching the instance default properties
|
// caching the instance default properties
|
||||||
|
|
|
@ -120,6 +120,7 @@ const defaultState = {
|
||||||
unseenAtTop: false,
|
unseenAtTop: false,
|
||||||
ignoreInactionableSeen: false,
|
ignoreInactionableSeen: false,
|
||||||
unsavedPostAction: 'confirm',
|
unsavedPostAction: 'confirm',
|
||||||
|
autoSaveDraft: false,
|
||||||
|
|
||||||
// Nasty stuff
|
// Nasty stuff
|
||||||
customEmoji: [],
|
customEmoji: [],
|
||||||
|
|
Loading…
Reference in a new issue