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
|
|
|
React = require 'react'
|
2015-04-25 02:33:10 +08:00
|
|
|
classNames = require 'classnames'
|
2015-03-21 08:51:49 +08:00
|
|
|
MessageItem = require "./message-item"
|
2015-06-27 05:06:31 +08:00
|
|
|
{Utils,
|
|
|
|
Actions,
|
2015-07-14 07:30:02 +08:00
|
|
|
Message,
|
|
|
|
DraftStore,
|
2015-06-27 05:06:31 +08:00
|
|
|
MessageStore,
|
2015-07-14 07:30:02 +08:00
|
|
|
DatabaseStore,
|
2015-06-27 05:06:31 +08:00
|
|
|
ComponentRegistry,
|
2015-07-16 23:54:20 +08:00
|
|
|
UpdateThreadsTask} = require("nylas-exports")
|
2015-06-27 05:06:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
{Spinner,
|
2015-06-06 02:50:55 +08:00
|
|
|
ScrollRegion,
|
2015-04-25 02:33:10 +08:00
|
|
|
ResizableRegion,
|
|
|
|
RetinaImg,
|
|
|
|
InjectedComponentSet,
|
2015-05-15 08:08:30 +08:00
|
|
|
InjectedComponent} = require('nylas-component-kit')
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-06-06 02:50:55 +08:00
|
|
|
class MessageListScrollTooltip extends React.Component
|
|
|
|
@displayName: 'MessageListScrollTooltip'
|
|
|
|
@propTypes:
|
|
|
|
viewportCenter: React.PropTypes.number.isRequired
|
|
|
|
totalHeight: React.PropTypes.number.isRequired
|
|
|
|
|
|
|
|
componentWillMount: =>
|
|
|
|
@setupForProps(@props)
|
|
|
|
|
|
|
|
componentWillReceiveProps: (newProps) =>
|
|
|
|
@setupForProps(newProps)
|
|
|
|
|
|
|
|
shouldComponentUpdate: (newProps, newState) =>
|
|
|
|
not _.isEqual(@state,newState)
|
|
|
|
|
|
|
|
setupForProps: (props) ->
|
|
|
|
# Technically, we could have MessageList provide the currently visible
|
|
|
|
# item index, but the DOM approach is simple and self-contained.
|
|
|
|
#
|
|
|
|
els = document.querySelectorAll('.message-item-wrap')
|
|
|
|
idx = _.findIndex els, (el) -> el.offsetTop > props.viewportCenter
|
|
|
|
if idx is -1
|
|
|
|
idx = els.length
|
|
|
|
|
|
|
|
@setState
|
|
|
|
idx: idx
|
|
|
|
count: els.length
|
|
|
|
|
|
|
|
render: ->
|
|
|
|
<div className="scroll-tooltip">
|
|
|
|
{@state.idx} of {@state.count}
|
|
|
|
</div>
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
class MessageList extends React.Component
|
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
|
|
|
@displayName: 'MessageList'
|
|
|
|
@containerRequired: false
|
2015-05-08 05:42:39 +08:00
|
|
|
@containerStyles:
|
|
|
|
minWidth: 500
|
|
|
|
maxWidth: 900
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @_getStateFromStores()
|
2015-06-23 06:49:52 +08:00
|
|
|
@state.minified = true
|
|
|
|
@MINIFY_THRESHOLD = 3
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentDidMount: =>
|
2015-06-27 07:08:41 +08:00
|
|
|
@_mounted = true
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
window.addEventListener("resize", @_onResize)
|
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
|
|
|
@_unsubscribers = []
|
|
|
|
@_unsubscribers.push MessageStore.listen @_onChange
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-06-27 05:06:31 +08:00
|
|
|
commands = _.extend {},
|
2015-06-27 05:47:14 +08:00
|
|
|
'core:star-item': => @_onStar()
|
2015-07-14 07:30:02 +08:00
|
|
|
'application:reply': => @_createReplyOrUpdateExistingDraft('reply')
|
|
|
|
'application:reply-all': => @_createReplyOrUpdateExistingDraft('reply-all')
|
2015-06-27 05:47:14 +08:00
|
|
|
'application:forward': => @_onForward()
|
2015-06-27 05:06:31 +08:00
|
|
|
|
|
|
|
@command_unsubscriber = atom.commands.add('body', commands)
|
|
|
|
|
2015-04-01 07:32:14 +08:00
|
|
|
# We don't need to listen to ThreadStore bcause MessageStore already
|
|
|
|
# listens to thead selection changes
|
|
|
|
|
2015-04-01 08:22:47 +08:00
|
|
|
if not @state.loading
|
2015-03-18 03:11:34 +08:00
|
|
|
@_prepareContentForDisplay()
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentWillUnmount: =>
|
2015-06-27 07:08:41 +08:00
|
|
|
@_mounted = false
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
unsubscribe() for unsubscribe in @_unsubscribers
|
2015-06-27 05:06:31 +08:00
|
|
|
@command_unsubscriber.dispose()
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
window.removeEventListener("resize", @_onResize)
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
shouldComponentUpdate: (nextProps, nextState) =>
|
2015-04-01 07:32:14 +08:00
|
|
|
not Utils.isEqualReact(nextProps, @props) or
|
|
|
|
not Utils.isEqualReact(nextState, @state)
|
2015-03-19 09:21:04 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
componentDidUpdate: (prevProps, prevState) =>
|
2015-04-01 08:22:47 +08:00
|
|
|
return if @state.loading
|
2015-03-18 03:11:34 +08:00
|
|
|
|
2015-04-01 08:22:47 +08:00
|
|
|
if prevState.loading
|
2015-04-01 05:31:01 +08:00
|
|
|
@_prepareContentForDisplay()
|
2015-04-01 08:22:47 +08:00
|
|
|
else
|
|
|
|
newDraftIds = @_newDraftIds(prevState)
|
|
|
|
newMessageIds = @_newMessageIds(prevState)
|
2015-06-06 02:38:30 +08:00
|
|
|
if newMessageIds.length > 0
|
2015-04-01 08:22:47 +08:00
|
|
|
@_prepareContentForDisplay()
|
2015-06-06 02:38:30 +08:00
|
|
|
else if newDraftIds.length > 0
|
2015-07-14 07:30:02 +08:00
|
|
|
@_focusDraft(@_getDraftElement(newDraftIds[0]))
|
2015-04-01 08:22:47 +08:00
|
|
|
@_prepareContentForDisplay()
|
2015-06-23 06:49:52 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_newDraftIds: (prevState) =>
|
2015-03-18 03:11:34 +08:00
|
|
|
oldDraftIds = _.map(_.filter((prevState.messages ? []), (m) -> m.draft), (m) -> m.id)
|
|
|
|
newDraftIds = _.map(_.filter((@state.messages ? []), (m) -> m.draft), (m) -> m.id)
|
2015-04-01 05:31:01 +08:00
|
|
|
return _.difference(newDraftIds, oldDraftIds) ? []
|
2015-03-18 03:11:34 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_newMessageIds: (prevState) =>
|
2015-04-01 05:31:01 +08:00
|
|
|
oldMessageIds = _.map(_.reject((prevState.messages ? []), (m) -> m.draft), (m) -> m.id)
|
|
|
|
newMessageIds = _.map(_.reject((@state.messages ? []), (m) -> m.draft), (m) -> m.id)
|
|
|
|
return _.difference(newMessageIds, oldMessageIds) ? []
|
2015-03-18 03:11:34 +08:00
|
|
|
|
2015-07-14 07:30:02 +08:00
|
|
|
_getDraftElement: (draftId) =>
|
|
|
|
@refs["composerItem-#{draftId}"]
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_focusDraft: (draftElement) =>
|
2015-06-06 02:38:30 +08:00
|
|
|
draftElement.focus()
|
2015-02-17 09:09:28 +08:00
|
|
|
|
2015-07-14 07:30:02 +08:00
|
|
|
_createReplyOrUpdateExistingDraft: (type) =>
|
|
|
|
unless type in ['reply', 'reply-all']
|
|
|
|
throw new Error("_createReplyOrUpdateExistingDraft called with #{type}, not reply or reply-all")
|
|
|
|
return unless @state.currentThread
|
|
|
|
|
|
|
|
last = _.last(@state.messages ? [])
|
|
|
|
|
|
|
|
# If the last message on the thread is already a draft, fetch the message it's
|
|
|
|
# in reply to and the draft session and change the participants.
|
|
|
|
if last.draft is true
|
|
|
|
data =
|
|
|
|
session: DraftStore.sessionForLocalId(@state.messageLocalIds[last.id])
|
|
|
|
replyToMessage: Promise.resolve(@state.messages[@state.messages.length - 2])
|
|
|
|
|
|
|
|
if last.replyToMessageId
|
|
|
|
msg = _.findWhere(@state.messages, {id: last.replyToMessageId})
|
|
|
|
if msg
|
|
|
|
data.replyToMessage = Promise.resolve(msg)
|
|
|
|
else
|
|
|
|
data.replyToMessage = DatabaseStore.find(Message, last.replyToMessageId)
|
|
|
|
|
|
|
|
Promise.props(data).then ({session, replyToMessage}) =>
|
|
|
|
return unless replyToMessage and session
|
|
|
|
draft = session.draft()
|
|
|
|
updated = {to: [].concat(draft.to), cc: [].concat(draft.cc)}
|
|
|
|
|
|
|
|
replySet = replyToMessage.participantsForReply()
|
|
|
|
replyAllSet = replyToMessage.participantsForReplyAll()
|
|
|
|
|
|
|
|
if type is 'reply'
|
|
|
|
targetSet = replySet
|
|
|
|
|
|
|
|
# Remove participants present in the reply-all set and not the reply set
|
|
|
|
for key in ['to', 'cc']
|
|
|
|
updated[key] = _.reject updated[key], (contact) ->
|
|
|
|
inReplySet = _.findWhere(replySet[key], {email: contact.email})
|
|
|
|
inReplyAllSet = _.findWhere(replyAllSet[key], {email: contact.email})
|
|
|
|
return inReplyAllSet and not inReplySet
|
|
|
|
else
|
|
|
|
# Add participants present in the reply-all set and not on the draft
|
|
|
|
# Switching to reply-all shouldn't really ever remove anyone.
|
|
|
|
targetSet = replyAllSet
|
|
|
|
|
|
|
|
for key in ['to', 'cc']
|
|
|
|
for contact in targetSet[key]
|
|
|
|
updated[key].push(contact) unless _.findWhere(updated[key], {email: contact.email})
|
|
|
|
|
|
|
|
session.changes.add(updated)
|
|
|
|
@_focusDraft(@_getDraftElement(last.id))
|
|
|
|
|
|
|
|
else
|
|
|
|
if type is 'reply'
|
|
|
|
Actions.composeReply(thread: @state.currentThread, message: last)
|
|
|
|
else
|
|
|
|
Actions.composeReplyAll(thread: @state.currentThread, message: last)
|
|
|
|
|
2015-06-27 05:47:14 +08:00
|
|
|
_onStar: =>
|
|
|
|
return unless @state.currentThread
|
2015-07-16 23:54:20 +08:00
|
|
|
threads = [@state.currentThread]
|
|
|
|
values = starred: (not @state.currentThread.starred)
|
|
|
|
task = new UpdateThreadsTask(threads, values)
|
2015-06-27 05:06:31 +08:00
|
|
|
Actions.queueTask(task)
|
|
|
|
|
2015-06-27 05:47:14 +08:00
|
|
|
_onForward: =>
|
|
|
|
return unless @state.currentThread
|
|
|
|
Actions.composeForward(thread: @state.currentThread)
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
render: =>
|
2015-04-28 09:26:04 +08:00
|
|
|
if not @state.currentThread?
|
|
|
|
return <div className="message-list" id="message-list"></div>
|
2015-03-19 09:21:04 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
wrapClass = classNames
|
2015-03-18 03:11:34 +08:00
|
|
|
"messages-wrap": true
|
|
|
|
"ready": @state.ready
|
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 07:19:05 +08:00
|
|
|
<div className="message-list" id="message-list">
|
2015-06-06 02:50:55 +08:00
|
|
|
<ScrollRegion tabIndex="-1"
|
2015-04-01 05:31:01 +08:00
|
|
|
className={wrapClass}
|
2015-06-06 02:50:55 +08:00
|
|
|
scrollTooltipComponent={MessageListScrollTooltip}
|
2015-04-01 05:31:01 +08:00
|
|
|
onScroll={_.debounce(@_cacheScrollPos, 100)}
|
|
|
|
ref="messageWrap">
|
2015-06-23 06:49:52 +08:00
|
|
|
{@_renderSubject()}
|
2015-06-06 02:50:55 +08:00
|
|
|
<div className="headers" style={position:'relative'}>
|
|
|
|
<InjectedComponentSet
|
|
|
|
className="message-list-notification-bars"
|
|
|
|
matching={role:"MessageListNotificationBar"}
|
|
|
|
exposedProps={thread: @state.currentThread}/>
|
|
|
|
<InjectedComponentSet
|
|
|
|
className="message-list-headers"
|
|
|
|
matching={role:"MessageListHeaders"}
|
|
|
|
exposedProps={thread: @state.currentThread}/>
|
|
|
|
</div>
|
2015-03-07 04:12:01 +08:00
|
|
|
{@_messageComponents()}
|
2015-06-06 02:50:55 +08:00
|
|
|
</ScrollRegion>
|
2015-03-18 03:11:34 +08:00
|
|
|
<Spinner visible={!@state.ready} />
|
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-06-23 06:49:52 +08:00
|
|
|
_renderSubject: ->
|
|
|
|
<div className="message-subject-wrap">
|
|
|
|
<div className="message-count">{@state.messages.length} {if @state.messages.length is 1 then "message" else "messages"}</div>
|
|
|
|
<div className="message-subject">{@state.currentThread?.subject}</div>
|
|
|
|
</div>
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_renderReplyArea: =>
|
2015-03-25 04:57:24 +08:00
|
|
|
if @_hasReplyArea()
|
2015-06-23 06:49:52 +08:00
|
|
|
<div className="footer-reply-area-wrap" onClick={@_onClickReplyArea} key={Utils.generateTempId()}>
|
2015-03-25 04:57:24 +08:00
|
|
|
<div className="footer-reply-area">
|
2015-06-06 02:40:44 +08:00
|
|
|
<RetinaImg name="#{@_replyType()}-footer.png" mode={RetinaImg.Mode.ContentIsMask}/>
|
|
|
|
<span className="reply-text">Write a reply…</span>
|
2015-03-25 04:57:24 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2015-06-23 06:49:52 +08:00
|
|
|
else return <div key={Utils.generateTempId()}></div>
|
2015-03-25 04:57:24 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_hasReplyArea: =>
|
2015-03-25 04:57:24 +08:00
|
|
|
not _.last(@state.messages)?.draft
|
|
|
|
|
|
|
|
# Either returns "reply" or "reply-all"
|
2015-04-25 02:33:10 +08:00
|
|
|
_replyType: =>
|
2015-03-25 04:57:24 +08:00
|
|
|
lastMsg = _.last(_.filter((@state.messages ? []), (m) -> not m.draft))
|
2015-07-14 07:30:02 +08:00
|
|
|
if lastMsg?.cc.length is 0 and lastMsg?.to.length is 1
|
|
|
|
return "reply"
|
|
|
|
else
|
|
|
|
return "reply-all"
|
2015-03-25 04:57:24 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_onClickReplyArea: =>
|
2015-07-14 07:30:02 +08:00
|
|
|
return unless @state.currentThread
|
|
|
|
@_createReplyOrUpdateExistingDraft(@_replyType())
|
2015-03-25 04:57:24 +08:00
|
|
|
|
2015-03-18 03:11:34 +08:00
|
|
|
# There may be a lot of iframes to load which may take an indeterminate
|
|
|
|
# amount of time. As long as there is more content being painted onto
|
|
|
|
# the page and our height is changing, keep waiting. Then scroll to message.
|
2015-04-25 02:33:10 +08:00
|
|
|
scrollToMessage: (msgDOMNode, done, location="top", stability=5) =>
|
2015-03-18 03:11:34 +08:00
|
|
|
return done() unless msgDOMNode?
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
messageWrap = React.findDOMNode(@refs.messageWrap)
|
2015-03-18 03:11:34 +08:00
|
|
|
lastHeight = -1
|
|
|
|
stableCount = 0
|
|
|
|
scrollIfSettled = =>
|
2015-06-27 07:08:41 +08:00
|
|
|
return unless @_mounted
|
2015-03-18 03:11:34 +08:00
|
|
|
messageWrapHeight = messageWrap.getBoundingClientRect().height
|
|
|
|
if messageWrapHeight isnt lastHeight
|
|
|
|
lastHeight = messageWrapHeight
|
|
|
|
stableCount = 0
|
|
|
|
else
|
|
|
|
stableCount += 1
|
2015-03-28 07:35:27 +08:00
|
|
|
if stableCount is stability
|
|
|
|
if location is "top"
|
|
|
|
messageWrap.scrollTop = msgDOMNode.offsetTop
|
|
|
|
else if location is "bottom"
|
|
|
|
offsetTop = msgDOMNode.offsetTop
|
|
|
|
messageHeight = msgDOMNode.getBoundingClientRect().height
|
|
|
|
messageWrap.scrollTop = offsetTop - (messageWrapHeight - messageHeight)
|
2015-03-18 03:11:34 +08:00
|
|
|
return done()
|
|
|
|
|
|
|
|
window.requestAnimationFrame -> scrollIfSettled(msgDOMNode, done)
|
|
|
|
|
2015-04-22 09:16:08 +08:00
|
|
|
scrollIfSettled()
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_messageComponents: =>
|
2015-06-06 02:38:30 +08:00
|
|
|
appliedInitialScroll = false
|
|
|
|
threadParticipants = @_threadParticipants()
|
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
|
|
|
components = []
|
|
|
|
|
2015-06-23 06:49:52 +08:00
|
|
|
messages = @_messagesWithMinification(@state.messages)
|
|
|
|
messages.forEach (message, idx) =>
|
|
|
|
|
|
|
|
if message.type is "minifiedBundle"
|
|
|
|
components.push(@_renderMinifiedBundle(message))
|
|
|
|
return
|
|
|
|
|
2015-03-26 03:41:48 +08:00
|
|
|
collapsed = !@state.messagesExpandedState[message.id]
|
|
|
|
|
2015-06-06 02:38:30 +08:00
|
|
|
initialScroll = not appliedInitialScroll and not collapsed and
|
2015-03-18 03:11:34 +08:00
|
|
|
((message.draft) or
|
|
|
|
(message.unread) or
|
|
|
|
(idx is @state.messages.length - 1 and idx > 0))
|
2015-06-06 02:38:30 +08:00
|
|
|
appliedInitialScroll ||= initialScroll
|
2015-03-18 03:11:34 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
className = classNames
|
2015-03-18 03:11:34 +08:00
|
|
|
"message-item-wrap": true
|
2015-06-23 06:49:52 +08:00
|
|
|
"before-reply-area": (messages.length - 1 is idx) and @_hasReplyArea()
|
2015-06-06 02:38:30 +08:00
|
|
|
"initial-scroll": initialScroll
|
2015-03-18 03:11:34 +08:00
|
|
|
"unread": message.unread
|
|
|
|
"draft": message.draft
|
2015-03-26 03:41:48 +08:00
|
|
|
"collapsed": collapsed
|
2015-03-18 03:11:34 +08:00
|
|
|
|
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
|
|
|
if message.draft
|
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
|
|
|
components.push <InjectedComponent matching={role:"Composer"}
|
2015-06-06 02:38:30 +08:00
|
|
|
exposedProps={ mode:"inline", localId:@state.messageLocalIds[message.id], onRequestScrollTo:@_onRequestScrollToComposer, threadId:@state.currentThread.id }
|
2015-07-14 07:30:02 +08:00
|
|
|
ref={"composerItem-#{message.id}"}
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
key={@state.messageLocalIds[message.id]}
|
2015-03-18 03:11:34 +08:00
|
|
|
className={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
|
|
|
else
|
|
|
|
components.push <MessageItem key={message.id}
|
2015-03-11 04:15:28 +08:00
|
|
|
thread={@state.currentThread}
|
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
|
|
|
message={message}
|
2015-03-11 01:08:04 +08:00
|
|
|
className={className}
|
2015-03-26 03:41:48 +08:00
|
|
|
collapsed={collapsed}
|
2015-06-23 06:49:52 +08:00
|
|
|
isLastMsg={(messages.length - 1 is idx)}
|
2015-06-06 02:38:30 +08:00
|
|
|
thread_participants={threadParticipants} />
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-06-23 06:49:52 +08:00
|
|
|
components.push @_renderReplyArea()
|
|
|
|
|
|
|
|
return components
|
|
|
|
|
|
|
|
_renderMinifiedBundle: (bundle) ->
|
|
|
|
|
|
|
|
BUNDLE_HEIGHT = 36
|
|
|
|
lines = bundle.messages[0...10]
|
|
|
|
h = Math.round(BUNDLE_HEIGHT / lines.length)
|
2015-03-25 04:57:24 +08:00
|
|
|
|
2015-06-23 06:49:52 +08:00
|
|
|
<div className="minified-bundle"
|
|
|
|
onClick={ => @setState minified: false }
|
|
|
|
key={Utils.generateTempId()}>
|
|
|
|
<div className="num-messages">{bundle.messages.length} older messages</div>
|
|
|
|
<div className="msg-lines" style={height: h*lines.length}>
|
|
|
|
{lines.map (msg, i) ->
|
|
|
|
<div style={height: h*2, top: -h*i} className="msg-line"></div>}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
_messagesWithMinification: (messages=[]) =>
|
|
|
|
return messages unless @state.minified
|
|
|
|
|
|
|
|
messages = _.clone(messages)
|
|
|
|
minifyRanges = []
|
|
|
|
consecutiveCollapsed = 0
|
|
|
|
|
|
|
|
messages.forEach (message, idx) =>
|
|
|
|
return if idx is 0 # Never minify the 1st message
|
|
|
|
|
|
|
|
expandState = @state.messagesExpandedState[message.id]
|
|
|
|
|
|
|
|
if not expandState
|
|
|
|
consecutiveCollapsed += 1
|
|
|
|
else
|
|
|
|
# We add a +1 because we don't minify the last collapsed message,
|
|
|
|
# but the MINIFY_THRESHOLD refers to the smallest N that can be in
|
|
|
|
# the "N older messages" minified block.
|
|
|
|
if expandState is "default"
|
|
|
|
minifyOffset = 1
|
|
|
|
else # if expandState is "explicit"
|
|
|
|
minifyOffset = 0
|
|
|
|
|
|
|
|
if consecutiveCollapsed >= @MINIFY_THRESHOLD + minifyOffset
|
|
|
|
minifyRanges.push
|
|
|
|
start: idx - consecutiveCollapsed
|
|
|
|
length: (consecutiveCollapsed - minifyOffset)
|
|
|
|
consecutiveCollapsed = 0
|
|
|
|
|
|
|
|
indexOffset = 0
|
|
|
|
for range in minifyRanges
|
|
|
|
start = range.start - indexOffset
|
|
|
|
minified =
|
|
|
|
type: "minifiedBundle"
|
|
|
|
messages: messages[start...(start+range.length)]
|
|
|
|
messages.splice(start, range.length, minified)
|
|
|
|
|
|
|
|
# While we removed `range.length` items, we also added 1 back in.
|
|
|
|
indexOffset += (range.length - 1)
|
|
|
|
|
|
|
|
return messages
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-06-06 02:38:30 +08:00
|
|
|
# Some child components (like the composer) might request that we scroll
|
2015-05-20 07:12:39 +08:00
|
|
|
# to a given location. If `selectionTop` is defined that means we should
|
|
|
|
# scroll to that absolute position.
|
|
|
|
#
|
|
|
|
# If messageId and location are defined, that means we want to scroll
|
|
|
|
# smoothly to the top of a particular message.
|
|
|
|
_onRequestScrollToComposer: ({messageId, location, selectionTop}={}) =>
|
2015-07-14 07:30:02 +08:00
|
|
|
composer = React.findDOMNode(@_getDraftElement(messageId))
|
2015-05-20 07:12:39 +08:00
|
|
|
if selectionTop
|
|
|
|
messageWrap = React.findDOMNode(@refs.messageWrap)
|
|
|
|
wrapRect = messageWrap.getBoundingClientRect()
|
|
|
|
if selectionTop < wrapRect.top or selectionTop > wrapRect.bottom
|
|
|
|
wrapMid = wrapRect.top + Math.abs(wrapRect.top - wrapRect.bottom) / 2
|
|
|
|
diff = selectionTop - wrapMid
|
|
|
|
messageWrap.scrollTop += diff
|
|
|
|
else
|
|
|
|
done = ->
|
|
|
|
location ?= "bottom"
|
|
|
|
@scrollToMessage(composer, done, location, 1)
|
|
|
|
|
|
|
|
_makeRectVisible: (rect) ->
|
|
|
|
messageWrap = React.findDOMNode(@refs.messageWrap)
|
2015-03-28 07:35:27 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_onChange: =>
|
2015-06-23 06:49:52 +08:00
|
|
|
newState = @_getStateFromStores()
|
|
|
|
if @state.currentThread isnt newState.currentThread
|
|
|
|
newState.minified = true
|
|
|
|
@setState(newState)
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_getStateFromStores: =>
|
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
|
|
|
messages: (MessageStore.items() ? [])
|
|
|
|
messageLocalIds: MessageStore.itemLocalIds()
|
2015-03-26 03:41:48 +08:00
|
|
|
messagesExpandedState: MessageStore.itemsExpandedState()
|
2015-04-01 08:19:17 +08:00
|
|
|
currentThread: MessageStore.thread()
|
2015-04-01 08:22:47 +08:00
|
|
|
loading: MessageStore.itemsLoading()
|
2015-03-18 03:11:34 +08:00
|
|
|
ready: if MessageStore.itemsLoading() then false else @state?.ready ? false
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_prepareContentForDisplay: =>
|
2015-06-06 02:38:30 +08:00
|
|
|
node = React.findDOMNode(@)
|
|
|
|
return unless node
|
|
|
|
initialScrollNode = node.querySelector(".initial-scroll")
|
|
|
|
@scrollToMessage initialScrollNode, =>
|
|
|
|
@setState(ready: true)
|
|
|
|
@_cacheScrollPos()
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_threadParticipants: =>
|
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
|
|
|
# We calculate the list of participants instead of grabbing it from
|
2015-03-11 04:15:28 +08:00
|
|
|
# `@state.currentThread.participants` because it makes it easier to
|
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
|
|
|
# test, is a better source of ground truth, and saves us from more
|
|
|
|
# dependencies.
|
|
|
|
participants = {}
|
|
|
|
for msg in (@state.messages ? [])
|
|
|
|
contacts = msg.participants()
|
|
|
|
for contact in contacts
|
|
|
|
if contact? and contact.email?.length > 0
|
|
|
|
participants[contact.email] = contact
|
|
|
|
return _.values(participants)
|
2015-02-21 05:17:11 +08:00
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_onResize: (event) =>
|
2015-04-01 05:31:01 +08:00
|
|
|
@_scrollToBottom() if @_wasAtBottom()
|
|
|
|
@_cacheScrollPos()
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_scrollToBottom: =>
|
|
|
|
messageWrap = React.findDOMNode(@refs.messageWrap)
|
2015-06-18 04:14:45 +08:00
|
|
|
return unless messageWrap
|
2015-04-01 05:31:01 +08:00
|
|
|
messageWrap.scrollTop = messageWrap.scrollHeight
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_cacheScrollPos: =>
|
|
|
|
messageWrap = React.findDOMNode(@refs.messageWrap)
|
2015-04-01 07:32:14 +08:00
|
|
|
return unless messageWrap
|
2015-04-01 05:31:01 +08:00
|
|
|
@_lastScrollTop = messageWrap.scrollTop
|
|
|
|
@_lastHeight = messageWrap.getBoundingClientRect().height
|
|
|
|
@_lastScrollHeight = messageWrap.scrollHeight
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
_wasAtBottom: =>
|
2015-04-01 05:31:01 +08:00
|
|
|
(@_lastScrollTop + @_lastHeight) >= @_lastScrollHeight
|
|
|
|
|
2015-04-25 02:33:10 +08:00
|
|
|
|
|
|
|
module.exports = MessageList
|