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,18 +727,24 @@ const PostStatusForm = {
}, },
saveDraft () { saveDraft () {
if (!this.disableDraft && if (!this.disableDraft &&
!this.saveInhibited && !this.saveInhibited) {
(this.newStatus.status || if (this.newStatus.status ||
this.newStatus.files?.length || this.newStatus.files?.length ||
this.newStatus.hasPoll this.newStatus.hasPoll) {
)) { return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus })
return this.$store.dispatch('addOrSaveDraft', { draft: this.newStatus }) .then(id => {
.then(id => { if (this.newStatus.id !== id) {
if (this.newStatus.id !== id) { this.newStatus.id = id
this.newStatus.id = id }
} this.savable = false
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() return Promise.resolve()
}, },