From 9129f18815cc01e9c6d13fa5bed0a172128c8640 Mon Sep 17 00:00:00 2001 From: Andrei Prigorshnev Date: Wed, 26 Oct 2022 04:59:08 +0400 Subject: [PATCH] DEV: make possible to pass both async and sync callbacks to the user status modal (#18712) --- .../discourse/app/controllers/preferences/account.js | 4 ++-- .../javascripts/discourse/app/controllers/user-status.js | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/account.js b/app/assets/javascripts/discourse/app/controllers/preferences/account.js index 5d1c18c1bd9..db8da6fd0d9 100644 --- a/app/assets/javascripts/discourse/app/controllers/preferences/account.js +++ b/app/assets/javascripts/discourse/app/controllers/preferences/account.js @@ -157,8 +157,8 @@ export default Controller.extend(CanCheckEmails, { modalClass: "user-status", model: { status, - saveAction: async (s) => this.set("newStatus", s), - deleteAction: async () => this.set("newStatus", null), + saveAction: (s) => this.set("newStatus", s), + deleteAction: () => this.set("newStatus", null), }, }); }, diff --git a/app/assets/javascripts/discourse/app/controllers/user-status.js b/app/assets/javascripts/discourse/app/controllers/user-status.js index b13b71161db..d9062b68786 100644 --- a/app/assets/javascripts/discourse/app/controllers/user-status.js +++ b/app/assets/javascripts/discourse/app/controllers/user-status.js @@ -52,8 +52,7 @@ export default Controller.extend(ModalFunctionality, { @action delete() { - this.model - .deleteAction() + Promise.resolve(this.model.deleteAction()) .then(() => this.send("closeModal")) .catch((e) => this._handleError(e)); }, @@ -71,8 +70,7 @@ export default Controller.extend(ModalFunctionality, { ends_at: this.status.endsAt?.toISOString(), }; - this.model - .saveAction(newStatus) + Promise.resolve(this.model.saveAction(newStatus)) .then(() => this.send("closeModal")) .catch((e) => this._handleError(e)); },