Clear draft if it is empty

This commit is contained in:
tusooa 2024-08-22 20:23:48 -04:00
parent 40c7236653
commit 89346369e0
No known key found for this signature in database
GPG key ID: 42AEC43D48433C51

View file

@ -727,11 +727,10 @@ const PostStatusForm = {
},
saveDraft () {
if (!this.disableDraft &&
!this.saveInhibited &&
(this.newStatus.status ||
!this.saveInhibited) {
if (this.newStatus.status ||
this.newStatus.files?.length ||
this.newStatus.hasPoll
)) {
this.newStatus.hasPoll) {
return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
.then(id => {
if (this.newStatus.id !== id) {
@ -739,6 +738,13 @@ const PostStatusForm = {
}
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()
},