Save draft immediately before unmount
This commit is contained in:
parent
4daa272fdf
commit
d4444cd0b1
|
@ -297,18 +297,8 @@ const PostStatusForm = {
|
|||
isEdit () {
|
||||
return typeof this.statusId !== 'undefined' && this.statusId.trim() !== ''
|
||||
},
|
||||
saveDraft () {
|
||||
return debounce(() => {
|
||||
if (this.newStatus.status) {
|
||||
console.debug('Saving status', this.newStatus)
|
||||
this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
|
||||
.then(id => {
|
||||
if (this.newStatus.id !== id) {
|
||||
this.newStatus.id = id
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 3000)
|
||||
debouncedSaveDraft () {
|
||||
return debounce(this.saveDraft, 3000)
|
||||
},
|
||||
...mapGetters(['mergedConfig']),
|
||||
...mapState({
|
||||
|
@ -323,11 +313,14 @@ const PostStatusForm = {
|
|||
}
|
||||
}
|
||||
},
|
||||
beforeUnmount () {
|
||||
this.saveDraft()
|
||||
},
|
||||
methods: {
|
||||
statusChanged () {
|
||||
this.autoPreview()
|
||||
this.updateIdempotencyKey()
|
||||
this.saveDraft()
|
||||
this.debouncedSaveDraft()
|
||||
},
|
||||
clearStatus () {
|
||||
const newStatus = this.newStatus
|
||||
|
@ -679,6 +672,17 @@ const PostStatusForm = {
|
|||
},
|
||||
propsToNative (props) {
|
||||
return propsToNative(props)
|
||||
},
|
||||
saveDraft () {
|
||||
if (this.newStatus.status) {
|
||||
console.debug('Saving status', this.newStatus)
|
||||
this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
|
||||
.then(id => {
|
||||
if (this.newStatus.id !== id) {
|
||||
this.newStatus.id = id
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue