Save draft immediately before unmount
This commit is contained in:
parent
1aa0901471
commit
1edada7e9d
|
@ -327,18 +327,8 @@ const PostStatusForm = {
|
||||||
|
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
saveDraft () {
|
debouncedSaveDraft () {
|
||||||
return debounce(() => {
|
return debounce(this.saveDraft, 3000)
|
||||||
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)
|
|
||||||
},
|
},
|
||||||
...mapGetters(['mergedConfig']),
|
...mapGetters(['mergedConfig']),
|
||||||
...mapState({
|
...mapState({
|
||||||
|
@ -353,11 +343,14 @@ const PostStatusForm = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
beforeUnmount () {
|
||||||
|
this.saveDraft()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
statusChanged () {
|
statusChanged () {
|
||||||
this.autoPreview()
|
this.autoPreview()
|
||||||
this.updateIdempotencyKey()
|
this.updateIdempotencyKey()
|
||||||
this.saveDraft()
|
this.debouncedSaveDraft()
|
||||||
},
|
},
|
||||||
clearStatus () {
|
clearStatus () {
|
||||||
const newStatus = this.newStatus
|
const newStatus = this.newStatus
|
||||||
|
@ -713,6 +706,17 @@ const PostStatusForm = {
|
||||||
},
|
},
|
||||||
propsToNative (props) {
|
propsToNative (props) {
|
||||||
return 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 a new issue