mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-06 08:08:10 +08:00
0468cb4b39
Summary: Initial hooks for reply to message Per-message actions and reply to message! Always commit changes before openinig popout composer Flip message display - newest at bottom like Gmail WIP specs New activity bar inspector for deltas Don't allow long polling connection to restart after end() called A bit of activity bar refactoring and filter options, clear Include "On ... someone wrote" in replies / fw Slightly more robust quoted text removal, detects "On..." Abort request to really end it Additional specs for draft store Test Plan: Run 20 new tests! Reviewers: evan Reviewed By: evan Differential Revision: https://review.inboxapp.com/D1230
66 lines
2 KiB
CoffeeScript
66 lines
2 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:archive-and-previous': @_onArchiveAndPrevious
|
|
'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(threadId: thread.id) if thread?
|
|
|
|
_onReplyAll: ->
|
|
thread = ThreadStore.selectedThread()
|
|
Actions.composeReplyAll(threadId: thread.id) if thread?
|
|
|
|
_onForward: ->
|
|
thread = ThreadStore.selectedThread()
|
|
Actions.composeForward(threadId: thread.id) if thread?
|
|
|
|
_onChange: ->
|
|
@setState(@_getStateFromStores())
|
|
|
|
_onArchiveAndPrevious: ->
|
|
@_onArchiveSelected()
|
|
@_onShiftSelectedIndex(-1)
|
|
|
|
_getStateFromStores: ->
|
|
count: ThreadStore.items().length
|
|
threads: ThreadStore.items()
|
|
selected: ThreadStore.selectedId()
|
|
|