commit: 1edada7e9dc05e2ae837acb9ea196e2f7e351e3a
parent 1aa0901471beb3f77feced1f2ac72726cb8aebfc
Author: tusooa <tusooa@kazv.moe>
Date: Fri, 10 Mar 2023 11:24:18 -0500
Save draft immediately before unmount
Diffstat:
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
@@ -327,18 +327,8 @@ const PostStatusForm = {
return false
},
- 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({
@@ -353,11 +343,14 @@ const PostStatusForm = {
}
}
},
+ beforeUnmount () {
+ this.saveDraft()
+ },
methods: {
statusChanged () {
this.autoPreview()
this.updateIdempotencyKey()
- this.saveDraft()
+ this.debouncedSaveDraft()
},
clearStatus () {
const newStatus = this.newStatus
@@ -713,6 +706,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
+ }
+ })
+ }
}
}
}