fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
React = require 'react'
|
2015-04-25 02:33:10 +08:00
|
|
|
classNames = require 'classnames'
|
2015-05-20 07:06:59 +08:00
|
|
|
_ = require 'underscore'
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
EmailFrame = require './email-frame'
|
2015-03-21 08:51:49 +08:00
|
|
|
MessageParticipants = require "./message-participants"
|
2015-11-07 07:53:21 +08:00
|
|
|
MessageItemBody = require "./message-item-body"
|
2015-03-21 08:51:49 +08:00
|
|
|
MessageTimestamp = require "./message-timestamp"
|
2015-06-23 06:49:52 +08:00
|
|
|
MessageControls = require './message-controls'
|
2015-03-26 09:25:08 +08:00
|
|
|
{Utils,
|
|
|
|
Actions,
|
|
|
|
MessageUtils,
|
feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.
This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.
When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.
Search bar doesn't need to do full refresh on clear if it never committed
Allow drafts to be switched to a different account when not in reply to an existing thread
Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal
Show many dots for many accounts in long polling status bar
add/remove accounts from prefs
Spec fixes!
Test Plan: Run tests, none broken!
Reviewers: evan, dillon
Reviewed By: evan, dillon
Differential Revision: https://phab.nylas.com/D1928
2015-08-22 06:29:58 +08:00
|
|
|
AccountStore,
|
2015-07-24 01:57:13 +08:00
|
|
|
MessageStore,
|
2015-08-18 07:23:12 +08:00
|
|
|
MessageBodyProcessor,
|
2015-07-09 00:51:33 +08:00
|
|
|
QuotedHTMLParser,
|
2015-03-26 09:25:08 +08:00
|
|
|
ComponentRegistry,
|
2015-05-15 08:08:30 +08:00
|
|
|
FileDownloadStore} = require 'nylas-exports'
|
2015-04-25 02:33:10 +08:00
|
|
|
{RetinaImg,
|
|
|
|
InjectedComponentSet,
|
2015-05-15 08:08:30 +08:00
|
|
|
InjectedComponent} = require 'nylas-component-kit'
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-03-19 04:54:34 +08:00
|
|
|
TransparentPixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR4nGNikAQAACIAHF/uBd8AAAAASUVORK5CYII="
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
class MessageItem extends React.Component
|
|
|
|
@displayName = 'MessageItem'
|
2015-03-11 01:08:04 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
@propTypes =
|
2015-03-11 01:08:04 +08:00
|
|
|
thread: React.PropTypes.object.isRequired
|
2015-03-07 08:08:34 +08:00
|
|
|
message: React.PropTypes.object.isRequired
|
2015-02-07 05:13:31 +08:00
|
|
|
collapsed: React.PropTypes.bool
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state =
|
|
|
|
# Holds the downloadData (if any) for all of our files. It's a hash
|
|
|
|
# keyed by a fileId. The value is the downloadData.
|
2015-06-16 09:48:17 +08:00
|
|
|
downloads: FileDownloadStore.downloadDataForFiles(@props.message.fileIds())
|
2015-04-25 02:33:10 +08:00
|
|
|
detailedHeaders: false
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentDidMount: =>
|
2015-02-07 05:13:31 +08:00
|
|
|
@_storeUnlisten = FileDownloadStore.listen(@_onDownloadStoreChange)
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentWillUnmount: =>
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
@_storeUnlisten() if @_storeUnlisten
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
shouldComponentUpdate: (nextProps, nextState) =>
|
2015-04-01 07:32:14 +08:00
|
|
|
not Utils.isEqualReact(nextProps, @props) or
|
|
|
|
not Utils.isEqualReact(nextState, @state)
|
2015-03-19 09:21:04 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
render: =>
|
2015-04-01 07:32:14 +08:00
|
|
|
if @props.collapsed
|
|
|
|
@_renderCollapsed()
|
|
|
|
else
|
|
|
|
@_renderFull()
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_renderCollapsed: =>
|
2015-06-26 01:35:06 +08:00
|
|
|
attachmentIcon = []
|
|
|
|
if @props.message.files.length > 0
|
|
|
|
attachmentIcon = <div className="collapsed-attachment"></div>
|
|
|
|
|
2015-04-01 07:32:14 +08:00
|
|
|
<div className={@props.className} onClick={@_toggleCollapsed}>
|
2015-07-31 09:29:38 +08:00
|
|
|
<div className="message-item-white-wrap">
|
|
|
|
<div className="message-item-area">
|
|
|
|
<div className="collapsed-from">
|
|
|
|
{@props.message.from?[0]?.displayFirstName()}
|
|
|
|
</div>
|
|
|
|
<div className="collapsed-snippet">
|
|
|
|
{@props.message.snippet}
|
|
|
|
</div>
|
|
|
|
<div className="collapsed-timestamp">
|
|
|
|
<MessageTimestamp date={@props.message.date} />
|
|
|
|
</div>
|
|
|
|
{attachmentIcon}
|
2015-04-01 07:32:14 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_renderFull: =>
|
2015-04-01 07:32:14 +08:00
|
|
|
<div className={@props.className}>
|
2015-07-31 09:29:38 +08:00
|
|
|
<div className="message-item-white-wrap">
|
|
|
|
<div className="message-item-area">
|
|
|
|
{@_renderHeader()}
|
2015-11-07 07:53:21 +08:00
|
|
|
<MessageItemBody message={@props.message} downloads={@state.downloads} />
|
2015-07-31 09:29:38 +08:00
|
|
|
{@_renderEvents()}
|
|
|
|
{@_renderAttachments()}
|
|
|
|
</div>
|
2015-04-01 07:32:14 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-03-10 02:17:22 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_renderHeader: =>
|
2015-08-05 10:35:56 +08:00
|
|
|
classes = classNames
|
|
|
|
"message-header": true
|
|
|
|
"pending": @props.pending
|
|
|
|
|
|
|
|
<header className={classes} onClick={@_onClickHeader}>
|
2015-03-11 01:08:04 +08:00
|
|
|
|
2015-08-04 08:19:07 +08:00
|
|
|
{@_renderHeaderSideItems()}
|
|
|
|
|
2015-04-01 07:32:14 +08:00
|
|
|
<div className="message-header-right">
|
|
|
|
<MessageTimestamp className="message-time selectable"
|
|
|
|
isDetailed={@state.detailedHeaders}
|
|
|
|
date={@props.message.date} />
|
2015-03-10 02:17:22 +08:00
|
|
|
|
2015-08-04 08:19:07 +08:00
|
|
|
{@_renderMessageControls()}
|
2015-04-01 07:32:14 +08:00
|
|
|
</div>
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-01 07:32:14 +08:00
|
|
|
<MessageParticipants to={@props.message.to}
|
|
|
|
cc={@props.message.cc}
|
|
|
|
bcc={@props.message.bcc}
|
|
|
|
from={@props.message.from}
|
|
|
|
subject={@props.message.subject}
|
2015-06-23 06:49:52 +08:00
|
|
|
onClick={@_onClickParticipants}
|
2015-04-01 07:32:14 +08:00
|
|
|
isDetailed={@state.detailedHeaders}
|
|
|
|
message_participants={@props.message.participants()} />
|
2015-03-11 01:08:04 +08:00
|
|
|
|
2015-07-24 06:18:08 +08:00
|
|
|
{@_renderFolder()}
|
2015-08-04 08:19:07 +08:00
|
|
|
{@_renderHeaderDetailToggle()}
|
2015-03-10 02:17:22 +08:00
|
|
|
|
2015-04-01 07:32:14 +08:00
|
|
|
</header>
|
|
|
|
|
2015-08-04 08:19:07 +08:00
|
|
|
_renderMessageControls: ->
|
|
|
|
<MessageControls thread={@props.thread} message={@props.message}/>
|
|
|
|
|
2015-07-24 06:18:08 +08:00
|
|
|
_renderFolder: =>
|
|
|
|
return [] unless @state.detailedHeaders and @props.message.folder
|
|
|
|
<div className="header-row">
|
|
|
|
<div className="header-label">Folder: </div>
|
|
|
|
<div className="header-name">{@props.message.folder.displayName}</div>
|
|
|
|
</div>
|
|
|
|
|
2015-06-23 06:49:52 +08:00
|
|
|
_onClickParticipants: (e) =>
|
|
|
|
el = e.target
|
|
|
|
while el isnt e.currentTarget
|
|
|
|
if "collapsed-participants" in el.classList
|
2015-07-24 06:18:08 +08:00
|
|
|
@setState(detailedHeaders: true)
|
2015-06-23 06:49:52 +08:00
|
|
|
e.stopPropagation()
|
|
|
|
return
|
|
|
|
el = el.parentElement
|
|
|
|
return
|
|
|
|
|
|
|
|
_onClickHeader: (e) =>
|
|
|
|
return if @state.detailedHeaders
|
|
|
|
el = e.target
|
|
|
|
while el isnt e.currentTarget
|
|
|
|
wl = ["message-header-right",
|
|
|
|
"collapsed-participants",
|
|
|
|
"header-toggle-control"]
|
|
|
|
if "message-header-right" in el.classList then return
|
|
|
|
if "collapsed-participants" in el.classList then return
|
|
|
|
el = el.parentElement
|
|
|
|
@_toggleCollapsed()
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_renderAttachments: =>
|
2015-04-01 07:32:14 +08:00
|
|
|
attachments = @_attachmentComponents()
|
|
|
|
if attachments.length > 0
|
|
|
|
<div className="attachments-area">{attachments}</div>
|
2015-03-26 03:41:48 +08:00
|
|
|
else
|
2015-04-01 07:32:14 +08:00
|
|
|
<div></div>
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-07-29 09:21:30 +08:00
|
|
|
_renderEvents: =>
|
|
|
|
events = @_eventComponents()
|
2015-07-31 23:23:03 +08:00
|
|
|
if events.length > 0 and not Utils.looksLikeGmailInvite(@props.message)
|
2015-07-29 09:21:30 +08:00
|
|
|
<div className="events-area">{events}</div>
|
|
|
|
else
|
|
|
|
<div></div>
|
|
|
|
|
2015-08-05 10:35:56 +08:00
|
|
|
_renderHeaderSideItems: ->
|
|
|
|
styles =
|
|
|
|
position: "absolute"
|
|
|
|
marginTop: -2
|
|
|
|
|
|
|
|
<div className="pending-spinner" style={styles}>
|
|
|
|
<RetinaImg ref="spinner"
|
|
|
|
name="sending-spinner.gif"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve}/>
|
|
|
|
</div>
|
2015-08-04 08:19:07 +08:00
|
|
|
|
|
|
|
_renderHeaderDetailToggle: =>
|
2015-08-05 10:35:56 +08:00
|
|
|
return null if @props.pending
|
2015-03-11 01:08:04 +08:00
|
|
|
if @state.detailedHeaders
|
2015-06-23 06:49:52 +08:00
|
|
|
<div className="header-toggle-control"
|
|
|
|
style={top: "18px", left: "-14px"}
|
2015-07-24 06:18:08 +08:00
|
|
|
onClick={ (e) => @setState(detailedHeaders: false); e.stopPropagation()}>
|
2015-06-06 02:40:44 +08:00
|
|
|
<RetinaImg name={"message-disclosure-triangle-active.png"} mode={RetinaImg.Mode.ContentIsMask}/>
|
2015-03-11 01:08:04 +08:00
|
|
|
</div>
|
|
|
|
else
|
2015-06-23 06:49:52 +08:00
|
|
|
<div className="header-toggle-control inactive"
|
|
|
|
style={top: "18px"}
|
2015-07-24 06:18:08 +08:00
|
|
|
onClick={ (e) => @setState(detailedHeaders: true); e.stopPropagation()}>
|
2015-06-06 02:40:44 +08:00
|
|
|
<RetinaImg name={"message-disclosure-triangle.png"} mode={RetinaImg.Mode.ContentIsMask}/>
|
2015-03-11 01:08:04 +08:00
|
|
|
</div>
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_toggleCollapsed: =>
|
2015-06-23 06:49:52 +08:00
|
|
|
return if @props.isLastMsg
|
2015-03-26 03:41:48 +08:00
|
|
|
Actions.toggleMessageIdExpanded(@props.message.id)
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_formatContacts: (contacts=[]) =>
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_attachmentComponents: =>
|
2015-06-12 02:52:49 +08:00
|
|
|
imageAttachments = []
|
|
|
|
otherAttachments = []
|
|
|
|
|
|
|
|
for file in (@props.message.files ? [])
|
|
|
|
continue unless @_isRealFile(file)
|
2015-11-25 08:16:58 +08:00
|
|
|
if Utils.shouldDisplayAsImage(file)
|
2015-06-12 02:52:49 +08:00
|
|
|
imageAttachments.push(file)
|
|
|
|
else
|
|
|
|
otherAttachments.push(file)
|
|
|
|
|
|
|
|
otherAttachments = otherAttachments.map (file) =>
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
<InjectedComponent
|
2015-07-16 04:15:05 +08:00
|
|
|
className="file-wrap"
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
matching={role:"Attachment"}
|
|
|
|
exposedProps={file:file, download: @state.downloads[file.id]}
|
|
|
|
key={file.id}/>
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-06-12 02:52:49 +08:00
|
|
|
imageAttachments = imageAttachments.map (file) =>
|
|
|
|
props =
|
|
|
|
file: file
|
|
|
|
download: @state.downloads[file.id]
|
|
|
|
targetPath: FileDownloadStore.pathForFile(file)
|
|
|
|
|
|
|
|
<InjectedComponent
|
2015-07-16 04:15:05 +08:00
|
|
|
className="file-wrap file-image-wrap"
|
2015-06-12 02:52:49 +08:00
|
|
|
matching={role:"Attachment:Image"}
|
|
|
|
exposedProps={props}
|
|
|
|
key={file.id} />
|
|
|
|
|
|
|
|
return otherAttachments.concat(imageAttachments)
|
|
|
|
|
2015-07-29 09:21:30 +08:00
|
|
|
_eventComponents: =>
|
|
|
|
events = @props.message.events.map (e) =>
|
|
|
|
<InjectedComponent
|
|
|
|
className="event-wrap"
|
|
|
|
matching={role:"Event"}
|
|
|
|
exposedProps={event:e}
|
|
|
|
key={e.id}/>
|
|
|
|
|
|
|
|
return events
|
|
|
|
|
2015-06-12 02:52:49 +08:00
|
|
|
_isRealFile: (file) ->
|
|
|
|
hasCIDInBody = file.contentId? and @props.message.body?.indexOf(file.contentId) > 0
|
2015-06-26 00:51:46 +08:00
|
|
|
return not hasCIDInBody
|
2015-06-12 02:52:49 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_onDownloadStoreChange: =>
|
2015-02-07 05:13:31 +08:00
|
|
|
@setState
|
2015-06-16 09:48:17 +08:00
|
|
|
downloads: FileDownloadStore.downloadDataForFiles(@props.message.fileIds())
|
2015-04-25 02:33:10 +08:00
|
|
|
|
feat(unsafe-components): Wrap injected components, catch exceptions, clean up ComponentRegistry
Summary:
This diff gives the ComponentRegistry a cleaner, smaller API. Instead of querying by name, location or role,
it's now just location and role, and you can register components for one or more location and one or more
roles without assigning the entries in the registry separate names.
When you register with the ComponentRegistry, the syntax is also cleaner and uses the component's displayName
instead of requiring you to provide a name. You also provide the actual component when unregistering, ensuring
that you can't unregister someone else's component.
InjectedComponent and InjectedComponentSet now wrap their children in UnsafeComponent, which prevents
render/component lifecycle problems from propogating.
Existing components have been updated:
1. maxWidth / minWidth are now containerStyles.maxWidth/minWidth
2. displayName is now required to use the CR.
3. containerRequired = false can be provided to exempt a component from being wrapped in an UnsafeComponent.
This is useful because it's slightly faster and keeps DOM flat.
This diff also makes the "Show Component Regions" more awesome. It displays column regions, since they now
use the InjectedComponentSet, and also shows for InjectedComponent as well as InjectedComponentSet.
Change ComponentRegistry syntax, lots more work on safely wrapping items. See description.
Fix for inline flexbox scenarios (message actions)
Allow ~/.inbox/packages to be symlinked to a github repo
Test Plan: Run tests!
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1457
2015-05-01 07:10:15 +08:00
|
|
|
module.exports = MessageItem
|