From 89346369e05cef4ba23637c162d8fe2046b85eb4 Mon Sep 17 00:00:00 2001 From: tusooa Date: Thu, 22 Aug 2024 20:23:48 -0400 Subject: [PATCH] Clear draft if it is empty --- .../post_status_form/post_status_form.js | 30 +++++++++++-------- 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 index a8c36df4..8eaa0594 100644 --- 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() },