UX: improves topic-notifications-button loading behavior (#9832)
This commit is contained in:
parent
38c05a4f07
commit
ab6737c44a
|
@ -62,13 +62,14 @@ const TopicDetails = RestModel.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
updateNotifications(level) {
|
updateNotifications(level) {
|
||||||
|
return ajax(`/t/${this.get("topic.id")}/notifications`, {
|
||||||
|
type: "POST",
|
||||||
|
data: { notification_level: level }
|
||||||
|
}).then(() => {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
notification_level: level,
|
notification_level: level,
|
||||||
notifications_reason_id: null
|
notifications_reason_id: null
|
||||||
});
|
});
|
||||||
return ajax(`/t/${this.get("topic.id")}/notifications`, {
|
|
||||||
type: "POST",
|
|
||||||
data: { notification_level: level }
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { action, computed } from "@ember/object";
|
import { action, computed } from "@ember/object";
|
||||||
import { later, cancel } from "@ember/runloop";
|
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
layoutName: "select-kit/templates/components/topic-notifications-button",
|
layoutName: "select-kit/templates/components/topic-notifications-button",
|
||||||
|
@ -17,22 +16,13 @@ export default Component.extend({
|
||||||
return this.isLoading ? "spinner" : null;
|
return this.isLoading ? "spinner" : null;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
willDestroyElement() {
|
|
||||||
this._super(...arguments);
|
|
||||||
|
|
||||||
this._endLoadingHandler && cancel(this._endLoadingHandler);
|
|
||||||
},
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
changeTopicNotificationLevel(levelId) {
|
changeTopicNotificationLevel(levelId) {
|
||||||
if (levelId !== this.notificationLevel) {
|
if (levelId !== this.notificationLevel) {
|
||||||
this.set("isLoading", true);
|
this.set("isLoading", true);
|
||||||
this.topic.details.updateNotifications(levelId).finally(() => {
|
this.topic.details
|
||||||
this._endLoadingHandler = later(
|
.updateNotifications(levelId)
|
||||||
() => this.set("isLoading", false),
|
.finally(() => this.set("isLoading", false));
|
||||||
250
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1026,14 +1026,6 @@ a.mention-group {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.topic-notifications-button.is-loading {
|
|
||||||
pointer-events: none;
|
|
||||||
user-select: none;
|
|
||||||
.topic-notifications-options {
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.pinned-button,
|
.pinned-button,
|
||||||
.topic-notifications-button {
|
.topic-notifications-button {
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
.topic-notifications-button {
|
||||||
|
&.is-loading {
|
||||||
|
pointer-events: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
.d-icon-spinner {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.selected-name .d-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topic-notifications-options {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue