This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/ignore-duration.js.es6
Tarek Khalil b1cb95fc23
FEATURE: Introduce ignore duration selection (#7266)
* FEATURE: Introducing new UI for tracking User's ignored or muted states
2019-03-29 10:14:53 +00:00

32 lines
923 B
JavaScript

import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Controller.extend(ModalFunctionality, {
loading: false,
ignoredUntil: null,
actions: {
ignore() {
if (!this.get("ignoredUntil")) {
this.flash(
I18n.t("user.user_notifications.ignore_duration_time_frame_required"),
"alert-error"
);
return;
}
this.set("loading", true);
this.get("model")
.updateNotificationLevel("ignore", this.get("ignoredUntil"))
.then(() => {
this.set("model.ignored", true);
this.set("model.muted", false);
if (this.get("onSuccess")) {
this.get("onSuccess")();
}
this.send("closeModal");
})
.catch(popupAjaxError)
.finally(() => this.set("loading", false));
}
}
});