Mailspring/internal_packages/thread-list/lib/thread-list-mixin.cjsx
Ben Gotow 0468cb4b39 feat(drafts) Reply to draft and minor fixes
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
2015-02-24 16:19:47 -08:00

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()