Introduce CTRL-E shortcut for archiving a conversation

This commit is contained in:
Scott Nonnenberg 2019-03-29 11:30:43 -07:00
parent 74cb808763
commit 81de5f9a76
3 changed files with 48 additions and 16 deletions

View file

@ -1,4 +1,5 @@
/* global
$,
ConversationController,
extension,
getConversations,
@ -146,6 +147,27 @@
this.openConversationAction = openConversationExternal;
// In the future this listener will be added by the conversation view itself. But
// because we currently have multiple converations open at once, we install just
// one global handler.
$(document).on('keydown', event => {
const { ctrlKey, key } = event;
// We can add Command-E as the Mac shortcut when we add it to our Electron menus:
// https://stackoverflow.com/questions/27380018/when-cmd-key-is-kept-pressed-keyup-is-not-triggered-for-any-other-key
// For now, it will stay as CTRL-E only
if (key === 'e' && ctrlKey) {
const state = this.store.getState();
const selectedId = state.conversations.selectedConversation;
const conversation = ConversationController.get(selectedId);
if (conversation && !conversation.get('isArchived')) {
conversation.setArchived(true);
conversation.trigger('unload');
}
}
});
this.listenTo(convoCollection, 'remove', conversation => {
const { id } = conversation || {};
conversationRemoved(id);