mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 13:44:41 +08:00
592374c0dc
Summary: This diff does two things: - It adds a new SwipeContainer that makes it easy to implement swipe gestures. This is built into listTabular, so you can create a list and define onSwipeLeft/Right to enable gestures. - It adds support for basic add/remove animations to the thread list. This works by adding a CSS transition to `top` and also leaving removed rows around for a specified time. (these times need to match.) Pretty much just cloned the core idea from TimeoutTransitionGroup. Test Plan: No tests yet Reviewers: evan, juan Reviewed By: evan Differential Revision: https://phab.nylas.com/D2581
65 lines
1.9 KiB
CoffeeScript
65 lines
1.9 KiB
CoffeeScript
React = require 'react'
|
|
{Actions,
|
|
CategoryStore,
|
|
TaskFactory,
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
|
|
|
class ThreadArchiveQuickAction extends React.Component
|
|
@displayName: 'ThreadArchiveQuickAction'
|
|
@propTypes:
|
|
thread: React.PropTypes.object
|
|
|
|
render: =>
|
|
mailboxPerspective = FocusedPerspectiveStore.current()
|
|
archive = null
|
|
|
|
if mailboxPerspective.canArchiveThreads()
|
|
archive = <div key="archive"
|
|
title="Archive"
|
|
style={{ order: 100 }}
|
|
className="btn action action-archive"
|
|
onClick={@_onArchive}></div>
|
|
return archive
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
_onArchive: (event) =>
|
|
tasks = TaskFactory.tasksForArchiving
|
|
threads: [@props.thread]
|
|
fromPerspective: FocusedPerspectiveStore.current()
|
|
Actions.queueTasks(tasks)
|
|
|
|
# Don't trigger the thread row click
|
|
event.stopPropagation()
|
|
|
|
class ThreadTrashQuickAction extends React.Component
|
|
@displayName: 'ThreadTrashQuickAction'
|
|
@propTypes:
|
|
thread: React.PropTypes.object
|
|
|
|
render: =>
|
|
mailboxPerspective = FocusedPerspectiveStore.current()
|
|
trash = null
|
|
|
|
if mailboxPerspective.canTrashThreads()
|
|
trash = <div key="remove"
|
|
title="Trash"
|
|
style={{ order: 110 }}
|
|
className='btn action action-trash'
|
|
onClick={@_onRemove}></div>
|
|
return trash
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
_onRemove: (event) =>
|
|
tasks = TaskFactory.tasksForMovingToTrash
|
|
threads: [@props.thread]
|
|
fromPerspective: FocusedPerspectiveStore.current()
|
|
Actions.queueTasks(tasks)
|
|
|
|
# Don't trigger the thread row click
|
|
event.stopPropagation()
|
|
|
|
module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }
|