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-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
|
|
|
|
2015-03-14 03:55:52 +08:00
|
|
|
{Utils,
|
|
|
|
Actions,
|
2015-03-03 07:33:58 +08:00
|
|
|
UndoManager,
|
2015-03-03 03:23:35 +08:00
|
|
|
DraftStore,
|
2015-05-15 08:08:30 +08:00
|
|
|
FileUploadStore} = require 'nylas-exports'
|
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-22 09:16:08 +08:00
|
|
|
{ResizableRegion,
|
2015-04-25 02:33:10 +08:00
|
|
|
InjectedComponentSet,
|
|
|
|
InjectedComponent,
|
2015-05-15 08:08:30 +08:00
|
|
|
RetinaImg} = require 'nylas-component-kit'
|
2015-02-28 07:34:37 +08:00
|
|
|
|
2015-03-21 08:51:49 +08:00
|
|
|
FileUploads = require './file-uploads'
|
|
|
|
ContenteditableComponent = require './contenteditable-component'
|
|
|
|
ParticipantsTextField = require './participants-text-field'
|
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
|
|
|
|
|
|
|
# The ComposerView is a unique React component because it (currently) is a
|
|
|
|
# singleton. Normally, the React way to do things would be to re-render the
|
2015-05-01 02:35:38 +08:00
|
|
|
# Composer with new props.
|
2015-05-01 04:08:29 +08:00
|
|
|
class ComposerView extends React.Component
|
|
|
|
@displayName: 'ComposerView'
|
|
|
|
|
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
|
|
|
@containerRequired: false
|
|
|
|
|
2015-05-08 06:28:44 +08:00
|
|
|
@propTypes:
|
|
|
|
localId: React.PropTypes.string.isRequired
|
|
|
|
|
|
|
|
# Either "inline" or "fullwindow"
|
|
|
|
mode: React.PropTypes.string
|
|
|
|
|
|
|
|
# If this composer is part of an existing thread (like inline
|
|
|
|
# composers) the threadId will be handed down
|
|
|
|
threadId: React.PropTypes.string
|
|
|
|
|
|
|
|
# Sometimes when changes in the composer happens it's desirable to
|
|
|
|
# have the parent scroll to a certain location. A parent component can
|
|
|
|
# pass a callback that gets called when this composer wants to be
|
|
|
|
# scrolled to.
|
|
|
|
onRequestScrollTo: React.PropTypes.func
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state =
|
|
|
|
populated: false
|
|
|
|
to: []
|
|
|
|
cc: []
|
|
|
|
bcc: []
|
|
|
|
body: ""
|
|
|
|
subject: ""
|
|
|
|
showcc: false
|
|
|
|
showbcc: false
|
|
|
|
showsubject: false
|
|
|
|
showQuotedText: false
|
2015-05-20 03:07:08 +08:00
|
|
|
isSending: DraftStore.isSendingDraft(@props.localId)
|
2015-05-01 04:08:29 +08:00
|
|
|
|
|
|
|
componentWillMount: =>
|
2015-03-24 07:33:28 +08:00
|
|
|
@_prepareForDraft(@props.localId)
|
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-05-01 04:08:29 +08:00
|
|
|
componentDidMount: =>
|
2015-03-13 05:48:56 +08:00
|
|
|
@_draftStoreUnlisten = DraftStore.listen @_onSendingStateChanged
|
2015-04-29 06:32:15 +08:00
|
|
|
@_keymapUnlisten = atom.commands.add '.composer-outer-wrap', {
|
2015-02-11 03:10:14 +08:00
|
|
|
'composer:show-and-focus-bcc': @_showAndFocusBcc
|
|
|
|
'composer:show-and-focus-cc': @_showAndFocusCc
|
2015-02-17 09:09:28 +08:00
|
|
|
'composer:focus-to': => @focus "textFieldTo"
|
|
|
|
'composer:send-message': => @_sendDraft()
|
2015-03-26 02:18:07 +08:00
|
|
|
'composer:delete-empty-draft': => @_deleteEmptyDraft()
|
2015-03-03 07:33:58 +08:00
|
|
|
"core:undo": @undo
|
|
|
|
"core:redo": @redo
|
2015-02-11 03:10:14 +08:00
|
|
|
}
|
2015-02-17 09:09:28 +08:00
|
|
|
if @props.mode is "fullwindow"
|
|
|
|
# Need to delay so the component can be fully painted. Focus doesn't
|
|
|
|
# work unless the element is on the page.
|
2015-03-24 06:57:19 +08:00
|
|
|
@focus "textFieldTo"
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
componentWillUnmount: =>
|
2015-05-16 01:45:18 +08:00
|
|
|
@_unmounted = true # rarf
|
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
|
|
|
@_teardownForDraft()
|
2015-03-13 05:48:56 +08:00
|
|
|
@_draftStoreUnlisten() if @_draftStoreUnlisten
|
2015-04-29 06:32:15 +08:00
|
|
|
@_keymapUnlisten.dispose() if @_keymapUnlisten
|
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-05-01 04:08:29 +08:00
|
|
|
componentDidUpdate: =>
|
2015-03-03 07:33:58 +08:00
|
|
|
# We want to use a temporary variable instead of putting this into the
|
|
|
|
# state. This is because the selection is a transient property that
|
|
|
|
# only needs to be applied once. It's not a long-living property of
|
|
|
|
# the state. We could call `setState` here, but this saves us from a
|
|
|
|
# re-rendering.
|
|
|
|
@_recoveredSelection = null if @_recoveredSelection?
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
componentWillReceiveProps: (newProps) =>
|
2015-03-24 07:33:28 +08:00
|
|
|
if newProps.localId isnt @props.localId
|
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
|
|
|
# When we're given a new draft localId, we have to stop listening to our
|
|
|
|
# current DraftStoreProxy, create a new one and listen to that. The simplest
|
|
|
|
# way to do this is to just re-call registerListeners.
|
|
|
|
@_teardownForDraft()
|
2015-03-24 07:33:28 +08:00
|
|
|
@_prepareForDraft(newProps.localId)
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_prepareForDraft: (localId) =>
|
2015-03-24 07:33:28 +08:00
|
|
|
@unlisteners = []
|
|
|
|
return unless localId
|
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-06 10:49:43 +08:00
|
|
|
# UndoManager must be ready before we call _onDraftChanged for the first time
|
|
|
|
@undoManager = new UndoManager
|
2015-05-16 01:45:18 +08:00
|
|
|
DraftStore.sessionForLocalId(localId).then(@_setupSession)
|
|
|
|
|
|
|
|
_setupSession: (proxy) =>
|
|
|
|
return if @_unmounted
|
|
|
|
return unless proxy.draftLocalId is @props.localId
|
|
|
|
@_proxy = proxy
|
2015-03-24 07:33:28 +08:00
|
|
|
@unlisteners.push @_proxy.listen(@_onDraftChanged)
|
2015-05-16 01:45:18 +08:00
|
|
|
@_onDraftChanged()
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_teardownForDraft: =>
|
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
|
|
|
unlisten() for unlisten in @unlisteners
|
2015-03-24 07:33:28 +08:00
|
|
|
if @_proxy
|
|
|
|
@_proxy.changes.commit()
|
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-05-01 04:08:29 +08:00
|
|
|
render: =>
|
2015-02-28 07:34:37 +08:00
|
|
|
if @props.mode is "inline"
|
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
|
|
|
<div className={@_wrapClasses()}>
|
2015-02-28 07:34:37 +08:00
|
|
|
<ResizableRegion handle={ResizableRegion.Handle.Bottom}>
|
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
|
|
|
{@_renderComposer()}
|
2015-02-28 07:34:37 +08:00
|
|
|
</ResizableRegion>
|
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
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<div className={@_wrapClasses()}>
|
|
|
|
{@_renderComposer()}
|
|
|
|
</div>
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_wrapClasses: =>
|
2015-03-18 03:11:34 +08:00
|
|
|
"composer-outer-wrap #{@props.className ? ""}"
|
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-05-01 04:08:29 +08:00
|
|
|
_renderComposer: =>
|
2015-03-11 02:23:31 +08:00
|
|
|
<div className="composer-inner-wrap" onDragOver={@_onDragNoop} onDragLeave={@_onDragNoop} onDragEnd={@_onDragNoop} onDrop={@_onDrop}>
|
2015-03-06 05:31:11 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
<div className="composer-cover"
|
|
|
|
style={display: (if @state.isSending then "block" else "none")}>
|
|
|
|
</div>
|
|
|
|
|
2015-03-06 05:31:11 +08:00
|
|
|
<div className="composer-content-wrap">
|
2015-03-05 10:47:48 +08:00
|
|
|
|
2015-03-06 05:31:11 +08:00
|
|
|
<div className="composer-participant-actions">
|
|
|
|
<span className="header-action"
|
|
|
|
style={display: @state.showcc and 'none' or 'inline'}
|
2015-03-24 06:57:19 +08:00
|
|
|
onClick={=> @_showAndFocusCc()}>Cc</span>
|
2015-03-05 07:52:40 +08:00
|
|
|
|
2015-03-06 05:31:11 +08:00
|
|
|
<span className="header-action"
|
|
|
|
style={display: @state.showbcc and 'none' or 'inline'}
|
2015-03-24 06:57:19 +08:00
|
|
|
onClick={=> @_showAndFocusBcc()}>Bcc</span>
|
2015-03-11 09:14:20 +08:00
|
|
|
|
|
|
|
<span className="header-action"
|
|
|
|
style={display: @state.showsubject and 'none' or 'initial'}
|
|
|
|
onClick={=> @setState {showsubject: true}}>Subject</span>
|
2015-03-18 07:19:40 +08:00
|
|
|
|
|
|
|
<span className="header-action"
|
|
|
|
data-tooltip="Popout composer"
|
|
|
|
style={{display: ((@props.mode is "fullwindow") and 'none' or 'initial'), paddingLeft: "1.5em"}}
|
|
|
|
onClick={@_popoutComposer}><RetinaImg name="composer-popout.png" style={{position: "relative", top: "-2px"}}/></span>
|
|
|
|
|
2015-03-06 05:31:11 +08:00
|
|
|
</div>
|
2015-03-05 07:52:40 +08:00
|
|
|
|
2015-03-06 05:31:11 +08:00
|
|
|
<ParticipantsTextField
|
|
|
|
ref="textFieldTo"
|
|
|
|
field='to'
|
2015-05-01 04:08:29 +08:00
|
|
|
visible={true}
|
2015-03-06 05:31:11 +08:00
|
|
|
change={@_onChangeParticipants}
|
|
|
|
participants={to: @state['to'], cc: @state['cc'], bcc: @state['bcc']}
|
|
|
|
tabIndex='102'/>
|
|
|
|
|
|
|
|
<ParticipantsTextField
|
|
|
|
ref="textFieldCc"
|
|
|
|
field='cc'
|
|
|
|
visible={@state.showcc}
|
|
|
|
change={@_onChangeParticipants}
|
2015-04-25 00:36:19 +08:00
|
|
|
onEmptied={=> @setState showcc: false}
|
2015-03-06 05:31:11 +08:00
|
|
|
participants={to: @state['to'], cc: @state['cc'], bcc: @state['bcc']}
|
|
|
|
tabIndex='103'/>
|
|
|
|
|
|
|
|
<ParticipantsTextField
|
|
|
|
ref="textFieldBcc"
|
|
|
|
field='bcc'
|
|
|
|
visible={@state.showbcc}
|
|
|
|
change={@_onChangeParticipants}
|
2015-04-25 00:36:19 +08:00
|
|
|
onEmptied={=> @setState showbcc: false}
|
2015-03-06 05:31:11 +08:00
|
|
|
participants={to: @state['to'], cc: @state['cc'], bcc: @state['bcc']}
|
|
|
|
tabIndex='104'/>
|
|
|
|
|
|
|
|
<div className="compose-subject-wrap"
|
|
|
|
style={display: @state.showsubject and 'initial' or 'none'}>
|
|
|
|
<input type="text"
|
|
|
|
key="subject"
|
|
|
|
name="subject"
|
|
|
|
tabIndex="108"
|
2015-03-20 07:57:41 +08:00
|
|
|
placeholder="Subject:"
|
2015-03-06 05:31:11 +08:00
|
|
|
disabled={not @state.showsubject}
|
|
|
|
className="compose-field compose-subject"
|
|
|
|
value={@state.subject}
|
|
|
|
onChange={@_onChangeSubject}/>
|
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
|
|
|
</div>
|
|
|
|
|
2015-03-06 05:31:11 +08:00
|
|
|
<div className="compose-body">
|
|
|
|
<ContenteditableComponent ref="contentBody"
|
|
|
|
html={@state.body}
|
|
|
|
onChange={@_onChangeBody}
|
2015-03-06 05:53:18 +08:00
|
|
|
style={@_precalcComposerCss}
|
2015-03-06 05:31:11 +08:00
|
|
|
initialSelectionSnapshot={@_recoveredSelection}
|
2015-03-18 07:19:40 +08:00
|
|
|
mode={{showQuotedText: @state.showQuotedText}}
|
|
|
|
onChangeMode={@_onChangeEditableMode}
|
2015-05-20 07:12:39 +08:00
|
|
|
onRequestScrollTo={@props.onRequestScrollTo}
|
2015-03-06 05:31:11 +08:00
|
|
|
tabIndex="109" />
|
|
|
|
</div>
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
{@_renderFooterRegions()}
|
2015-03-21 01:23:50 +08:00
|
|
|
</div>
|
2015-04-22 09:16:08 +08:00
|
|
|
|
2015-03-18 07:19:40 +08:00
|
|
|
<div className="composer-action-bar-wrap">
|
2015-04-25 02:33:10 +08:00
|
|
|
{@_renderActionsRegion()}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_renderFooterRegions: =>
|
2015-04-25 02:33:10 +08:00
|
|
|
return <div></div> unless @props.localId
|
|
|
|
|
|
|
|
<span>
|
|
|
|
<div className="attachments-area">
|
|
|
|
{
|
|
|
|
(@state.files ? []).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 matching={role:"Attachment"}
|
|
|
|
exposedProps={file: file, removable: true, messageLocalId: @props.localId}
|
|
|
|
key={file.filename} />
|
2015-04-25 02:33:10 +08:00
|
|
|
}
|
|
|
|
<FileUploads localId={@props.localId} />
|
|
|
|
</div>
|
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
|
|
|
<InjectedComponentSet
|
|
|
|
matching={role: "Composer:Footer"}
|
2015-05-08 06:28:44 +08:00
|
|
|
exposedProps={draftLocalId:@props.localId, threadId: @props.threadId}/>
|
2015-04-25 02:33:10 +08:00
|
|
|
</span>
|
2015-04-22 09:16:08 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_renderActionsRegion: =>
|
2015-04-25 02:33:10 +08:00
|
|
|
return <div></div> unless @props.localId
|
2015-03-18 07:19:40 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
<InjectedComponentSet className="composer-action-bar-content"
|
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: "Composer:ActionButton"}
|
2015-05-08 06:28:44 +08:00
|
|
|
exposedProps={draftLocalId:@props.localId, threadId: @props.threadId}>
|
2015-03-18 07:19:40 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
<button className="btn btn-toolbar btn-trash" style={order: 100}
|
|
|
|
data-tooltip="Delete draft"
|
|
|
|
onClick={@_destroyDraft}><RetinaImg name="toolbar-trash.png" /></button>
|
2015-04-22 09:16:08 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
<button className="btn btn-toolbar btn-attach" style={order: 50}
|
|
|
|
data-tooltip="Attach file"
|
|
|
|
onClick={@_attachFile}><RetinaImg name="toolbar-attach.png"/></button>
|
2015-04-22 09:16:08 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
<div style={order: 0, flex: 1} />
|
|
|
|
|
|
|
|
<button className="btn btn-toolbar btn-emphasis btn-send" style={order: -100}
|
|
|
|
data-tooltip="Send message"
|
|
|
|
ref="sendButton"
|
|
|
|
onClick={@_sendDraft}><RetinaImg name="toolbar-send.png" /> Send</button>
|
|
|
|
|
|
|
|
</InjectedComponentSet>
|
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-18 03:11:34 +08:00
|
|
|
# Focus the composer view. Chooses the appropriate field to start
|
|
|
|
# focused depending on the draft type, or you can pass a field as
|
|
|
|
# the first parameter.
|
2015-05-01 04:08:29 +08:00
|
|
|
focus: (field = null) =>
|
2015-03-18 03:11:34 +08:00
|
|
|
if component?.isForwardedMessage()
|
|
|
|
field ?= "textFieldTo"
|
|
|
|
else
|
|
|
|
field ?= "contentBody"
|
|
|
|
|
2015-03-24 06:57:19 +08:00
|
|
|
_.delay =>
|
|
|
|
@refs[field]?.focus?()
|
|
|
|
, 150
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
isForwardedMessage: =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return false if not @_proxy
|
2015-03-11 09:44:33 +08:00
|
|
|
draft = @_proxy.draft()
|
2015-03-26 03:41:48 +08:00
|
|
|
Utils.isForwardedMessage(draft)
|
2015-03-11 09:44:33 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onDraftChanged: =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return unless @_proxy
|
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
|
|
|
draft = @_proxy.draft()
|
2015-03-03 07:33:58 +08:00
|
|
|
if not @_initialHistorySave
|
|
|
|
@_saveToHistory()
|
|
|
|
@_initialHistorySave = true
|
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
|
|
|
state =
|
|
|
|
to: draft.to
|
|
|
|
cc: draft.cc
|
|
|
|
bcc: draft.bcc
|
|
|
|
files: draft.files
|
|
|
|
subject: draft.subject
|
|
|
|
body: draft.body
|
|
|
|
|
|
|
|
if !@state.populated
|
|
|
|
_.extend state,
|
2015-03-05 10:47:48 +08:00
|
|
|
showcc: not _.isEmpty(draft.cc)
|
|
|
|
showbcc: not _.isEmpty(draft.bcc)
|
2015-03-11 09:27:10 +08:00
|
|
|
showsubject: @_shouldShowSubject()
|
2015-03-14 04:17:18 +08:00
|
|
|
showQuotedText: @isForwardedMessage()
|
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
|
|
|
populated: true
|
|
|
|
|
|
|
|
@setState(state)
|
2015-03-11 09:27:10 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_shouldShowSubject: =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return false unless @_proxy
|
2015-03-11 09:27:10 +08:00
|
|
|
draft = @_proxy.draft()
|
|
|
|
if _.isEmpty(draft.subject ? "") then return true
|
2015-03-11 09:44:33 +08:00
|
|
|
else if @isForwardedMessage() then return true
|
2015-03-11 09:27:10 +08:00
|
|
|
else return false
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onDragNoop: (e) =>
|
2015-03-27 09:25:21 +08:00
|
|
|
e.preventDefault()
|
2015-03-11 02:23:31 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onDrop: (e) =>
|
2015-03-11 02:23:31 +08:00
|
|
|
e.preventDefault()
|
|
|
|
for file in e.dataTransfer.files
|
|
|
|
Actions.attachFilePath({path: file.path, messageLocalId: @props.localId})
|
2015-03-27 09:25:21 +08:00
|
|
|
true
|
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-05-01 04:08:29 +08:00
|
|
|
_onChangeParticipants: (changes={}) => @_addToProxy(changes)
|
|
|
|
_onChangeSubject: (event) => @_addToProxy(subject: event.target.value)
|
2015-03-28 07:35:27 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onChangeBody: (event) =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return unless @_proxy
|
2015-03-28 07:35:27 +08:00
|
|
|
if @_getSelections().currentSelection?.atEndOfContent
|
|
|
|
@props.onRequestScrollTo?(messageId: @_proxy.draft().id, location: "bottom")
|
|
|
|
@_addToProxy(body: event.target.value)
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onChangeEditableMode: ({showQuotedText}) =>
|
2015-03-18 07:19:40 +08:00
|
|
|
@setState showQuotedText: showQuotedText
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_addToProxy: (changes={}, source={}) =>
|
2015-03-24 07:33:28 +08:00
|
|
|
return unless @_proxy
|
|
|
|
|
2015-03-03 07:33:58 +08:00
|
|
|
selections = @_getSelections()
|
|
|
|
|
|
|
|
oldDraft = @_proxy.draft()
|
2015-03-24 07:33:28 +08:00
|
|
|
return if _.all changes, (change, key) -> _.isEqual(change, oldDraft[key])
|
2015-03-03 07:33:58 +08:00
|
|
|
@_proxy.changes.add(changes)
|
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-03 07:33:58 +08:00
|
|
|
@_saveToHistory(selections) unless source.fromUndoManager
|
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-05-01 04:08:29 +08:00
|
|
|
_popoutComposer: =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return unless @_proxy
|
2015-02-25 08:19:47 +08:00
|
|
|
@_proxy.changes.commit()
|
2015-02-07 06:46:30 +08:00
|
|
|
Actions.composePopoutDraft @props.localId
|
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-05-01 04:08:29 +08:00
|
|
|
_sendDraft: (options = {}) =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return unless @_proxy
|
2015-03-13 05:48:56 +08:00
|
|
|
return if @state.isSending
|
2015-02-07 06:46:30 +08:00
|
|
|
draft = @_proxy.draft()
|
|
|
|
remote = require('remote')
|
|
|
|
dialog = remote.require('dialog')
|
|
|
|
|
|
|
|
if [].concat(draft.to, draft.cc, draft.bcc).length is 0
|
|
|
|
dialog.showMessageBox(remote.getCurrentWindow(), {
|
|
|
|
type: 'warning',
|
|
|
|
buttons: ['Edit Message'],
|
|
|
|
message: 'Cannot Send',
|
|
|
|
detail: 'You need to provide one or more recipients before sending the message.'
|
|
|
|
})
|
|
|
|
return
|
|
|
|
|
|
|
|
warnings = []
|
|
|
|
if draft.subject.length is 0
|
|
|
|
warnings.push('without a subject line')
|
2015-03-14 03:55:52 +08:00
|
|
|
if (draft.files ? []).length is 0 and @_hasAttachment(draft.body)
|
2015-02-07 06:46:30 +08:00
|
|
|
warnings.push('without an attachment')
|
|
|
|
|
2015-05-16 01:53:22 +08:00
|
|
|
# Warn if the user tries to send a message with no body, or with a body that
|
|
|
|
# is only quoted text and not a forward.
|
|
|
|
body = draft.body.toLowerCase().trim()
|
|
|
|
forwarded = Utils.isForwardedMessage(draft)
|
|
|
|
quotedTextIndex = Utils.quotedTextIndex(body)
|
|
|
|
if body.length is 0 or (0 <= quotedTextIndex <= 10 and not forwarded)
|
|
|
|
warnings.push('without a body')
|
|
|
|
|
2015-03-21 01:23:50 +08:00
|
|
|
# Check third party warnings added via DraftStore extensions
|
|
|
|
for extension in DraftStore.extensions()
|
|
|
|
continue unless extension.warningsForSending
|
|
|
|
warnings = warnings.concat(extension.warningsForSending(draft))
|
|
|
|
|
2015-02-07 06:46:30 +08:00
|
|
|
if warnings.length > 0 and not options.force
|
|
|
|
dialog.showMessageBox remote.getCurrentWindow(), {
|
|
|
|
type: 'warning',
|
|
|
|
buttons: ['Cancel', 'Send Anyway'],
|
|
|
|
message: 'Are you sure?',
|
|
|
|
detail: "Send #{warnings.join(' and ')}?"
|
|
|
|
}, (response) =>
|
|
|
|
if response is 1 # button array index 1
|
|
|
|
@_sendDraft({force: true})
|
|
|
|
return
|
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
|
|
|
|
|
|
|
Actions.sendDraft(@props.localId)
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_hasAttachment: (body) =>
|
2015-03-14 03:55:52 +08:00
|
|
|
body = body.toLowerCase().trim()
|
|
|
|
attachIndex = body.indexOf("attach")
|
|
|
|
if attachIndex >= 0
|
|
|
|
quotedTextIndex = Utils.quotedTextIndex(body)
|
|
|
|
if quotedTextIndex >= 0
|
|
|
|
return (attachIndex < quotedTextIndex)
|
|
|
|
else return true
|
|
|
|
else return false
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_destroyDraft: =>
|
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
|
|
|
Actions.destroyDraft(@props.localId)
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_attachFile: =>
|
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
|
|
|
Actions.attachFile({messageLocalId: @props.localId})
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_showAndFocusBcc: =>
|
2015-03-05 10:47:48 +08:00
|
|
|
@setState {showbcc: true}
|
2015-02-17 09:09:28 +08:00
|
|
|
@focus "textFieldBcc"
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_showAndFocusCc: =>
|
2015-02-11 03:10:14 +08:00
|
|
|
@setState {showcc: true}
|
2015-02-17 09:09:28 +08:00
|
|
|
@focus "textFieldCc"
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onSendingStateChanged: =>
|
2015-05-20 03:07:08 +08:00
|
|
|
@setState isSending: DraftStore.isSendingDraft(@props.localId)
|
2015-03-13 05:48:56 +08:00
|
|
|
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
undo: (event) =>
|
2015-03-03 07:33:58 +08:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
historyItem = @undoManager.undo() ? {}
|
|
|
|
return unless historyItem.state?
|
|
|
|
|
|
|
|
@_recoveredSelection = historyItem.currentSelection
|
|
|
|
@_addToProxy historyItem.state, fromUndoManager: true
|
2015-05-20 07:12:39 +08:00
|
|
|
@_recoveredSelection = null
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
redo: (event) =>
|
2015-03-03 07:33:58 +08:00
|
|
|
event.preventDefault()
|
|
|
|
event.stopPropagation()
|
|
|
|
historyItem = @undoManager.redo() ? {}
|
|
|
|
return unless historyItem.state?
|
|
|
|
|
|
|
|
@_recoveredSelection = historyItem.currentSelection
|
|
|
|
@_addToProxy historyItem.state, fromUndoManager: true
|
2015-05-20 07:12:39 +08:00
|
|
|
@_recoveredSelection = null
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_getSelections: =>
|
2015-03-03 07:33:58 +08:00
|
|
|
currentSelection: @refs.contentBody?.getCurrentSelection?()
|
|
|
|
previousSelection: @refs.contentBody?.getPreviousSelection?()
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_saveToHistory: (selections) =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return unless @_proxy
|
2015-03-03 07:33:58 +08:00
|
|
|
selections ?= @_getSelections()
|
|
|
|
|
|
|
|
newDraft = @_proxy.draft()
|
|
|
|
|
|
|
|
historyItem =
|
|
|
|
previousSelection: selections.previousSelection
|
|
|
|
currentSelection: selections.currentSelection
|
|
|
|
state:
|
|
|
|
body: _.clone newDraft.body
|
|
|
|
subject: _.clone newDraft.subject
|
|
|
|
to: _.clone newDraft.to
|
|
|
|
cc: _.clone newDraft.cc
|
|
|
|
bcc: _.clone newDraft.bcc
|
|
|
|
|
|
|
|
lastState = @undoManager.current()
|
|
|
|
if lastState?
|
|
|
|
lastState.currentSelection = historyItem.previousSelection
|
|
|
|
|
|
|
|
@undoManager.saveToHistory(historyItem)
|
2015-03-26 02:18:07 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_deleteEmptyDraft: =>
|
2015-05-16 01:45:18 +08:00
|
|
|
return unless @_proxy
|
2015-03-26 02:18:07 +08:00
|
|
|
if @_proxy.draft().pristine then Actions.destroyDraft(@props.localId)
|
2015-05-01 04:08:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
module.exports = ComposerView
|