FIX: makes tracking shortcuts working when tracking button is not visible (#9575)

This commit is contained in:
Joffrey JAFFEUX 2020-04-28 20:12:16 +02:00 committed by GitHub
parent a8308e73e7
commit 07e6452759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 58 deletions

View File

@ -380,28 +380,30 @@ export default {
.send("showKeyboardShortcutsHelp"); .send("showKeyboardShortcutsHelp");
}, },
setTrackingToMuted(event) { setTrackingToMuted() {
throttle(this, "_setTracking", { id: 0, event }, INPUT_DELAY, true); throttle(this, "_setTracking", 0, INPUT_DELAY, true);
}, },
setTrackingToRegular(event) { setTrackingToRegular() {
throttle(this, "_setTracking", { id: 1, event }, INPUT_DELAY, true); throttle(this, "_setTracking", 1, INPUT_DELAY, true);
}, },
setTrackingToTracking(event) { setTrackingToTracking() {
throttle(this, "_setTracking", { id: 2, event }, INPUT_DELAY, true); throttle(this, "_setTracking", 2, INPUT_DELAY, true);
}, },
setTrackingToWatching(event) { setTrackingToWatching() {
throttle(this, "_setTracking", { id: 3, event }, INPUT_DELAY, true); throttle(this, "_setTracking", 3, INPUT_DELAY, true);
}, },
_setTracking(params) { _setTracking(levelId) {
this.appEvents.trigger("topic-notifications-button:changed", { const topic = this.currentTopic();
type: "notification",
id: params.id, if (!topic) {
event: params.event return;
}); }
topic.details.updateNotifications(levelId);
}, },
sendToTopicListItemView(action, elem) { sendToTopicListItemView(action, elem) {

View File

@ -1,4 +1,5 @@
import Component from "@ember/component"; import Component from "@ember/component";
import { action } from "@ember/object";
export default Component.extend({ export default Component.extend({
layoutName: "select-kit/templates/components/topic-notifications-button", layoutName: "select-kit/templates/components/topic-notifications-button",
@ -6,51 +7,13 @@ export default Component.extend({
appendReason: true, appendReason: true,
showFullTitle: true, showFullTitle: true,
placement: "bottom-start", placement: "bottom-start",
notificationLevel: null,
topic: null,
didInsertElement() { @action
this._super(...arguments); changeTopicNotificationLevel(levelId) {
if (levelId !== this.notificationLevel) {
if (!this.mountedAsWidget) { this.topic.details.updateNotifications(levelId);
this.appEvents.on(
"topic-notifications-button:changed",
this,
"_changeTopicNotificationLevel"
);
}
},
willDestroyElement() {
this._super(...arguments);
if (!this.mountedAsWidget) {
this.appEvents.off(
"topic-notifications-button:changed",
this,
"_changeTopicNotificationLevel"
);
}
},
_changeTopicNotificationLevel(level) {
// this change is coming from a keyboard event
if (level.event) {
const topicSectionNode = level.event.target.querySelector("#topic");
if (topicSectionNode && topicSectionNode.dataset.topicId) {
const topicId = parseInt(topicSectionNode.dataset.topicId, 10);
if (topicId && topicId !== this.topic.id) {
return;
}
}
}
if (level.id !== this.notificationLevel) {
this.topic.details.updateNotifications(level.id);
}
},
actions: {
changeTopicNotificationLevel(level, notification) {
this._changeTopicNotificationLevel(notification);
} }
} }
}); });