mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
4f8366a772
Summary: This diff essentially inverts the behavior of native-key-bindings. Instead of opting-in to native-key-bindings, they're applied UNLESS there's an override-key-bindings class. I think this may be a better solution for us since we don't often want to override behavior like Copy and Select All. Test Plan: No new tests on this one... Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1124
61 lines
1.8 KiB
CoffeeScript
61 lines
1.8 KiB
CoffeeScript
_ = require 'underscore-plus'
|
|
{Actions, ThreadStore} = require 'inbox-exports'
|
|
|
|
module.exports =
|
|
ThreadListMixin =
|
|
getInitialState: ->
|
|
@_getStateFromStores()
|
|
|
|
componentDidMount: ->
|
|
@thread_store_unsubscribe = ThreadStore.listen @_onChange
|
|
@thread_unsubscriber = atom.commands.add '.thread-list-container', {
|
|
'thread-list:star-thread': @_onStarThread
|
|
}
|
|
@body_unsubscriber = atom.commands.add 'body', {
|
|
'application:previous-message': => @_onShiftSelectedIndex(-1)
|
|
'application:next-message': => @_onShiftSelectedIndex(1)
|
|
'application:archive-thread': @_onArchiveSelected
|
|
'application:reply': @_onReply
|
|
'application:reply-all': @_onReplyAll
|
|
'application:forward': @_onForward
|
|
}
|
|
|
|
componentWillUnmount: ->
|
|
@thread_store_unsubscribe()
|
|
@thread_unsubscriber.dispose()
|
|
@body_unsubscriber.dispose()
|
|
|
|
_onShiftSelectedIndex: (delta) ->
|
|
item = _.find @state.threads, (thread) => thread.id == @state?.selected
|
|
index = if item then @state.threads.indexOf(item) else -1
|
|
index = Math.max(0, Math.min(index + delta, @state.threads.length-1))
|
|
Actions.selectThreadId(@state.threads[index].id)
|
|
|
|
_onArchiveSelected: ->
|
|
thread = ThreadStore.selectedThread()
|
|
thread.archive() if thread
|
|
|
|
_onStarThread: ->
|
|
thread = ThreadStore.selectedThread()
|
|
thread.toggleStar() if thread
|
|
|
|
_onReply: ->
|
|
thread = ThreadStore.selectedThread()
|
|
Actions.composeReply(thread.id) if thread?
|
|
|
|
_onReplyAll: ->
|
|
thread = ThreadStore.selectedThread()
|
|
Actions.composeReplyAll(thread.id) if thread?
|
|
|
|
_onForward: ->
|
|
thread = ThreadStore.selectedThread()
|
|
Actions.composeForward(thread.id) if thread?
|
|
|
|
_onChange: ->
|
|
@setState(@_getStateFromStores())
|
|
|
|
_getStateFromStores: ->
|
|
count: ThreadStore.items().length
|
|
threads: ThreadStore.items()
|
|
selected: ThreadStore.selectedId()
|
|
|