From f41fcad6c333e25f82bfa3634ec95d122721c541 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Wed, 27 May 2020 18:16:48 +1000 Subject: [PATCH] FIX: opening cancel draft dialog broke autosave cancelComposer would leak a promise that never got resolved if you aborted cancelling a composer. This change ensured the promise will always be resolved --- .../discourse/app/controllers/composer.js | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.js index f76b948f8cb..41fb94c9103 100644 --- a/app/assets/javascripts/discourse/app/controllers/composer.js +++ b/app/assets/javascripts/discourse/app/controllers/composer.js @@ -1043,8 +1043,8 @@ export default Controller.extend({ if (differentDraft) { this.model.clearState(); this.close(); - resolve(); } + resolve(); } }, { @@ -1052,22 +1052,30 @@ export default Controller.extend({ class: "btn-danger", callback: result => { if (result) { - this.destroyDraft().then(() => { - this.model.clearState(); - this.close(); - resolve(); - }); + this.destroyDraft() + .then(() => { + this.model.clearState(); + this.close(); + }) + .finally(() => { + resolve(); + }); + } else { + resolve(); } } } ]); } else { // it is possible there is some sort of crazy draft with no body ... just give up on it - this.destroyDraft().then(() => { - this.model.clearState(); - this.close(); - resolve(); - }); + this.destroyDraft() + .then(() => { + this.model.clearState(); + this.close(); + }) + .finally(() => { + resolve(); + }); } });