Mailspring/internal_packages/thread-list/lib/draft-list.cjsx
Ben Gotow 21a32ac57f fix(*): Message list container styles, logout exceptions, composer logic cleanup
Summary:
This diff makes a couple changes:

- New drafts are no longer created in the composer component. Draft creation is back in the draft store where it belongs!
  - This means that the Draft List doesn't *always* contain two extra drafts, which are the unopened hot windows.
- Windows never show until they're loaded, which means windows open slowly vs. opening empty. I think the former is preferable but it's easy to change.
- Login window is now sized *before* it's shown instead of afterwards
- The mailto: behavior is now handled by the DraftStore, which gets rid of the whole draftInitialJSON thing that never made any sense.

fix(login) Make login window show at the correct size

logout from edgehill completely

Fix draft delete issue

Don't show windows, hot or cold, until they've loaded

Move logic for responding to mailto links into the draft store

Always fire `windowPropsChanged` after packages load or the window is shown

Show more error codes in red in activity bar

Make sure DraftStoreProxy doesn't interrupt the rendering of the composer with a new draft

Fix account-sidebar scroll issue, maybe?

Test Plan: Run tests!

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1479
2015-05-07 14:42:39 -07:00

79 lines
2.2 KiB
CoffeeScript

_ = require 'underscore-plus'
React = require 'react'
{ListTabular,
MultiselectList,
InjectedComponent} = require 'ui-components'
{timestamp, subject} = require './formatting-utils'
{Actions,
DatabaseStore} = require 'inbox-exports'
DraftListStore = require './draft-list-store'
class DraftList extends React.Component
@displayName: 'DraftList'
@containerRequired: false
componentWillMount: =>
snippet = (html) =>
@draftSanitizer ?= document.createElement('div')
@draftSanitizer.innerHTML = html
text = @draftSanitizer.innerText
text[0..140]
c1 = new ListTabular.Column
name: "Name"
width: 200
resolver: (draft) =>
<div className="participants">
<InjectedComponent matching={role:"Participants"}
exposedProps={participants: [].concat(draft.to, draft.cc, draft.bcc), clickable: false}/>
</div>
c2 = new ListTabular.Column
name: "Message"
flex: 4
resolver: (draft) =>
attachments = []
if draft.files?.length > 0
attachments = <div className="thread-icon thread-icon-attachment"></div>
<span className="details">
<span className="subject">{subject(draft.subject)}</span>
<span className="snippet">{snippet(draft.body)}</span>
{attachments}
</span>
c3 = new ListTabular.Column
name: "Date"
flex: 1
resolver: (draft) =>
<span className="timestamp">{timestamp(draft.date)}</span>
@columns = [c1, c2, c3]
@commands =
'core:remove-item': @_onDelete
render: =>
<MultiselectList
dataStore={DraftListStore}
columns={@columns}
commands={@commands}
onDoubleClick={@_onDoubleClick}
itemPropsProvider={ -> {} }
className="draft-list"
collection="draft" />
_onDoubleClick: (item) =>
DatabaseStore.localIdForModel(item).then (localId) ->
Actions.composePopoutDraft(localId)
# Additional Commands
_onDelete: ({focusedId}) =>
item = DraftListStore.view().getById(focusedId)
return unless item
DatabaseStore.localIdForModel(item).then (localId) ->
Actions.destroyDraft(localId)
module.exports = DraftList