2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2020-05-23 12:56:13 +08:00
|
|
|
import { action, computed } from "@ember/object";
|
2020-08-29 03:30:20 +08:00
|
|
|
import layout from "select-kit/templates/components/topic-notifications-button";
|
2020-02-03 21:22:14 +08:00
|
|
|
|
2019-10-24 00:30:52 +08:00
|
|
|
export default Component.extend({
|
2020-08-29 03:30:20 +08:00
|
|
|
layout,
|
2020-02-03 21:22:14 +08:00
|
|
|
classNames: ["topic-notifications-button"],
|
2020-05-23 12:56:13 +08:00
|
|
|
classNameBindings: ["isLoading"],
|
2020-02-03 21:22:14 +08:00
|
|
|
appendReason: true,
|
2017-10-20 03:51:08 +08:00
|
|
|
showFullTitle: true,
|
2020-04-29 02:12:16 +08:00
|
|
|
notificationLevel: null,
|
|
|
|
topic: null,
|
2020-05-18 20:07:40 +08:00
|
|
|
showCaret: true,
|
2020-05-23 12:56:13 +08:00
|
|
|
isLoading: false,
|
|
|
|
icon: computed("isLoading", function () {
|
|
|
|
return this.isLoading ? "spinner" : null;
|
|
|
|
}),
|
2020-05-19 19:27:57 +08:00
|
|
|
|
2020-04-29 02:12:16 +08:00
|
|
|
@action
|
|
|
|
changeTopicNotificationLevel(levelId) {
|
|
|
|
if (levelId !== this.notificationLevel) {
|
2020-05-23 12:56:13 +08:00
|
|
|
this.set("isLoading", true);
|
|
|
|
this.topic.details
|
|
|
|
.updateNotifications(levelId)
|
|
|
|
.finally(() => this.set("isLoading", false));
|
2020-02-03 21:22:14 +08:00
|
|
|
}
|
|
|
|
},
|
2017-10-20 03:51:08 +08:00
|
|
|
});
|