FIX: Correct the topic notification keyboard shortcuts

This commit is contained in:
cpradio 2016-06-17 14:39:45 -04:00
parent a4a53d6500
commit 145ee10f40
3 changed files with 33 additions and 4 deletions

View file

@ -11,5 +11,10 @@ export default MountWidget.extend({
@observes('topic.details.notification_level')
_triggerRerender() {
this.queueRerender();
},
didInsertElement() {
this._super();
this.dispatch('topic-notifications-button:keyboard-trigger', 'topic-notifications-button');
}
});

View file

@ -32,10 +32,10 @@ const bindings = {
'j': {handler: 'selectDown', anonymous: true},
'k': {handler: 'selectUp', anonymous: true},
'l': {click: '.topic-post.selected button.toggle-like'},
'm m': {click: 'div.notification-options li[data-id="0"] a'}, // mark topic as muted
'm r': {click: 'div.notification-options li[data-id="1"] a'}, // mark topic as regular
'm t': {click: 'div.notification-options li[data-id="2"] a'}, // mark topic as tracking
'm w': {click: 'div.notification-options li[data-id="3"] a'}, // mark topic as watching
'm m': {handler: 'setTrackingToMuted'}, // mark topic as muted
'm r': {handler: 'setTrackingToRegular'}, // mark topic as regular
'm t': {handler: 'setTrackingToTracking'}, // mark topic as tracking
'm w': {handler: 'setTrackingToWatching'}, // mark topic as watching
'o,enter': {click: '.topic-list tr.selected a.title', anonymous: true}, // open selected topic
'p': {handler: 'showCurrentUser'},
'q': {handler: 'quoteReply'},
@ -179,6 +179,22 @@ export default {
this.container.lookup('controller:application').send('showKeyboardShortcutsHelp');
},
setTrackingToMuted(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 0, event});
},
setTrackingToRegular(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 1, event});
},
setTrackingToTracking(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 2, event});
},
setTrackingToWatching(event) {
this.appEvents.trigger('topic-notifications-button:keyboard-trigger', {type: 'notification', id: 3, event});
},
sendToTopicListItemView(action) {
const elem = $('tr.selected.topic-list-item.ember-view')[0];
if (elem) {

View file

@ -86,5 +86,13 @@ export default createWidget('topic-notifications-button', {
notificationLevelChanged(id) {
this.state.expanded = false;
return this.attrs.topic.get('details').updateNotifications(id);
},
topicNotificationsButtonKeyboardTrigger(msg) {
switch(msg.type) {
case 'notification':
this.notificationLevelChanged(msg.id);
break;
}
}
});