commit: 89346369e05cef4ba23637c162d8fe2046b85eb4
parent 40c7236653cc7cc2bee53cade9f688805c056ab8
Author: tusooa <tusooa@kazv.moe>
Date: Thu, 22 Aug 2024 20:23:48 -0400
Clear draft if it is empty
Diffstat:
1 file changed, 18 insertions(+), 12 deletions(-)
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
@@ -727,18 +727,24 @@ const PostStatusForm = {
},
saveDraft () {
if (!this.disableDraft &&
- !this.saveInhibited &&
- (this.newStatus.status ||
- this.newStatus.files?.length ||
- this.newStatus.hasPoll
- )) {
- return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
- .then(id => {
- if (this.newStatus.id !== id) {
- this.newStatus.id = id
- }
- this.savable = false
- })
+ !this.saveInhibited) {
+ if (this.newStatus.status ||
+ this.newStatus.files?.length ||
+ this.newStatus.hasPoll) {
+ return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
+ .then(id => {
+ if (this.newStatus.id !== id) {
+ this.newStatus.id = id
+ }
+ this.savable = false
+ })
+ } else if (this.newStatus.id) {
+ // There is a draft, but there is nothing in it, clear it
+ return this.abandonDraft()
+ .then(() => {
+ this.savable = false
+ })
+ }
}
return Promise.resolve()
},