Skip to content

A platform for community discussion. Free, open, simple.

DEV: make possible to pass both async and sync callbacks to the user status modal (#18712)

Andrei Prigorshnev9129f18815cc
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));
},