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
|
|
|
_ = require "underscore-plus"
|
|
|
|
proxyquire = require "proxyquire"
|
|
|
|
|
|
|
|
React = require "react/addons"
|
|
|
|
ReactTestUtils = React.addons.TestUtils
|
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
{Actions,
|
|
|
|
Contact,
|
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,
|
|
|
|
Namespace,
|
2015-03-13 05:48:56 +08:00
|
|
|
DraftStore,
|
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
|
|
|
DatabaseStore,
|
2015-02-11 03:10:14 +08:00
|
|
|
InboxTestUtils,
|
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
|
|
|
NamespaceStore} = require "inbox-exports"
|
|
|
|
|
|
|
|
u1 = new Contact(name: "Christine Spang", email: "spang@inboxapp.com")
|
|
|
|
u2 = new Contact(name: "Michael Grinich", email: "mg@inboxapp.com")
|
|
|
|
u3 = new Contact(name: "Evan Morikawa", email: "evan@inboxapp.com")
|
|
|
|
u4 = new Contact(name: "Zoë Leiper", email: "zip@inboxapp.com")
|
|
|
|
u5 = new Contact(name: "Ben Gotow", email: "ben@inboxapp.com")
|
|
|
|
users = [u1, u2, u3, u4, u5]
|
|
|
|
NamespaceStore._current = new Namespace(
|
|
|
|
{name: u1.name, provider: "inbox", emailAddress: u1.email})
|
|
|
|
|
|
|
|
reactStub = (className) ->
|
|
|
|
React.createClass({render: -> <div className={className}>{@props.children}</div>})
|
|
|
|
|
2015-02-11 03:10:14 +08:00
|
|
|
textFieldStub = (className) ->
|
|
|
|
React.createClass
|
|
|
|
render: -> <div className={className}>{@props.children}</div>
|
|
|
|
focus: ->
|
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
draftStoreProxyStub = (localId, returnedDraft) ->
|
2015-02-19 06:09:46 +08:00
|
|
|
listen: -> ->
|
2015-03-13 05:48:56 +08:00
|
|
|
draft: -> (returnedDraft ? new Message(draft: true))
|
2015-02-11 03:10:14 +08:00
|
|
|
changes:
|
|
|
|
add: ->
|
|
|
|
commit: ->
|
|
|
|
applyToModel: ->
|
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
|
|
|
|
|
|
|
searchContactStub = (email) ->
|
|
|
|
_.filter(users, (u) u.email.toLowerCase() is email.toLowerCase())
|
|
|
|
|
2015-03-21 08:51:49 +08:00
|
|
|
ComposerView = proxyquire "../lib/composer-view",
|
|
|
|
"./file-uploads": reactStub("file-uploads")
|
|
|
|
"./participants-text-field": textFieldStub("")
|
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
|
|
|
"inbox-exports":
|
|
|
|
ContactStore:
|
|
|
|
searchContacts: (email) -> searchContactStub
|
|
|
|
ComponentRegistry:
|
|
|
|
listen: -> ->
|
|
|
|
findViewByName: (component) -> reactStub(component)
|
|
|
|
findAllViewsByRole: (role) -> [reactStub('a'),reactStub('b')]
|
2015-03-21 01:23:50 +08:00
|
|
|
findAllByRole: (role) -> [{view:reactStub('a'), name:'a'},{view:reactStub('b'),name:'b'}]
|
2015-03-13 05:48:56 +08:00
|
|
|
DraftStore: DraftStore
|
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
|
|
|
|
|
|
|
beforeEach ->
|
|
|
|
# The NamespaceStore isn't set yet in the new window, populate it first.
|
|
|
|
NamespaceStore.populateItems().then ->
|
|
|
|
new Promise (resolve, reject) ->
|
|
|
|
draft = new Message
|
|
|
|
from: [NamespaceStore.current().me()]
|
|
|
|
date: (new Date)
|
2015-02-07 06:41:59 +08:00
|
|
|
draft: 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
|
|
|
namespaceId: NamespaceStore.current().id
|
|
|
|
|
|
|
|
DatabaseStore.persistModel(draft).then ->
|
|
|
|
DatabaseStore.localIdForModel(draft).then(resolve).catch(reject)
|
|
|
|
.catch(reject)
|
|
|
|
|
2015-02-11 03:10:14 +08:00
|
|
|
describe "A blank composer view", ->
|
|
|
|
beforeEach ->
|
|
|
|
@composer = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ComposerView />
|
|
|
|
)
|
|
|
|
@composer.setState
|
|
|
|
body: ""
|
|
|
|
|
|
|
|
it 'should render into the document', ->
|
|
|
|
expect(ReactTestUtils.isCompositeComponentWithType @composer, ComposerView).toBe true
|
|
|
|
|
|
|
|
describe "testing keyboard inputs", ->
|
2015-03-13 05:48:56 +08:00
|
|
|
it "shows and focuses on bcc field", ->
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
it "shows and focuses on cc field", ->
|
2015-02-17 09:09:28 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
it "shows and focuses on bcc field when already open", ->
|
2015-02-17 09:09:28 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
describe "populated composer", ->
|
|
|
|
# This will setup the mocks necessary to make the composer element (once
|
|
|
|
# mounted) think it's attached to the given draft. This mocks out the
|
|
|
|
# proxy system used by the composer.
|
|
|
|
DRAFT_LOCAL_ID = "local-123"
|
|
|
|
useDraft = (draftAttributes={}) ->
|
2015-03-26 03:41:48 +08:00
|
|
|
@draft = new Message _.extend({draft: true, body: ""}, draftAttributes)
|
2015-03-13 05:48:56 +08:00
|
|
|
spyOn(DraftStore, "sessionForLocalId").andCallFake (localId) =>
|
|
|
|
return draftStoreProxyStub(localId, @draft)
|
2015-02-17 09:09:28 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
useFullDraft = ->
|
|
|
|
useDraft.call @,
|
|
|
|
from: [u1]
|
|
|
|
to: [u2]
|
|
|
|
cc: [u3, u4]
|
|
|
|
bcc: [u5]
|
|
|
|
subject: "Test Message 1"
|
|
|
|
body: "Hello <b>World</b><br/> This is a test"
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
makeComposer = ->
|
|
|
|
@composer = ReactTestUtils.renderIntoDocument(
|
|
|
|
<ComposerView localId={DRAFT_LOCAL_ID} />
|
|
|
|
)
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
describe "When displaying info from a draft", ->
|
|
|
|
beforeEach ->
|
|
|
|
useFullDraft.apply(@)
|
|
|
|
makeComposer.call(@)
|
2015-02-11 03:10:14 +08:00
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
it "attaches the draft to the proxy", ->
|
|
|
|
expect(@draft).toBeDefined()
|
|
|
|
expect(@composer._proxy.draft()).toBe @draft
|
|
|
|
|
|
|
|
it "set the state based on the draft", ->
|
|
|
|
expect(@composer.state.from).toBeUndefined()
|
|
|
|
expect(@composer.state.to).toEqual [u2]
|
|
|
|
expect(@composer.state.cc).toEqual [u3, u4]
|
|
|
|
expect(@composer.state.bcc).toEqual [u5]
|
|
|
|
expect(@composer.state.subject).toEqual "Test Message 1"
|
|
|
|
expect(@composer.state.body).toEqual "Hello <b>World</b><br/> This is a test"
|
|
|
|
|
|
|
|
describe "when deciding whether or not to show the subject", ->
|
2015-03-11 09:27:10 +08:00
|
|
|
it "shows the subject when the subject is empty", ->
|
2015-03-13 05:48:56 +08:00
|
|
|
useDraft.call @, subject: ""
|
|
|
|
makeComposer.call @
|
2015-03-11 09:27:10 +08:00
|
|
|
expect(@composer._shouldShowSubject()).toBe true
|
|
|
|
|
|
|
|
it "shows the subject when the subject looks like a fwd", ->
|
2015-03-13 05:48:56 +08:00
|
|
|
useDraft.call @, subject: "Fwd: This is the message"
|
|
|
|
makeComposer.call @
|
2015-03-11 09:27:10 +08:00
|
|
|
expect(@composer._shouldShowSubject()).toBe true
|
|
|
|
|
|
|
|
it "shows the subject when the subject looks like a fwd", ->
|
2015-03-13 05:48:56 +08:00
|
|
|
useDraft.call @, subject: "fwd foo"
|
|
|
|
makeComposer.call @
|
2015-03-11 09:27:10 +08:00
|
|
|
expect(@composer._shouldShowSubject()).toBe true
|
|
|
|
|
|
|
|
it "doesn't show subject when subject has fwd text in it", ->
|
2015-03-13 05:48:56 +08:00
|
|
|
useDraft.call @, subject: "Trick fwd"
|
|
|
|
makeComposer.call @
|
2015-03-11 09:27:10 +08:00
|
|
|
expect(@composer._shouldShowSubject()).toBe false
|
|
|
|
|
|
|
|
it "doesn't show the subject otherwise", ->
|
2015-03-13 05:48:56 +08:00
|
|
|
useDraft.call @, subject: "Foo bar baz"
|
|
|
|
makeComposer.call @
|
2015-03-11 09:27:10 +08:00
|
|
|
expect(@composer._shouldShowSubject()).toBe false
|
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
describe "when deciding whether or not to show cc and bcc", ->
|
|
|
|
it "doesn't show cc when there's no one to cc", ->
|
|
|
|
useDraft.call @, cc: []
|
|
|
|
makeComposer.call @
|
|
|
|
expect(@composer.state.showcc).toBe false
|
|
|
|
|
|
|
|
it "shows cc when populated", ->
|
|
|
|
useDraft.call @, cc: [u1,u2]
|
|
|
|
makeComposer.call @
|
|
|
|
expect(@composer.state.showcc).toBe true
|
|
|
|
|
|
|
|
it "doesn't show bcc when there's no one to bcc", ->
|
|
|
|
useDraft.call @, bcc: []
|
|
|
|
makeComposer.call @
|
|
|
|
expect(@composer.state.showbcc).toBe false
|
|
|
|
|
|
|
|
it "shows bcc when populated", ->
|
|
|
|
useDraft.call @, bcc: [u2,u3]
|
|
|
|
makeComposer.call @
|
|
|
|
expect(@composer.state.showbcc).toBe true
|
|
|
|
|
|
|
|
describe "When sending a message", ->
|
|
|
|
beforeEach ->
|
|
|
|
remote = require('remote')
|
|
|
|
@dialog = remote.require('dialog')
|
|
|
|
spyOn(remote, "getCurrentWindow")
|
|
|
|
spyOn(@dialog, "showMessageBox")
|
|
|
|
spyOn(Actions, "sendDraft")
|
|
|
|
DraftStore._sendingState = {}
|
|
|
|
|
|
|
|
it "shows a warning if there are no recipients", ->
|
|
|
|
useDraft.call @, subject: "no recipients"
|
|
|
|
makeComposer.call(@)
|
|
|
|
@composer._sendDraft()
|
|
|
|
expect(Actions.sendDraft).not.toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).toHaveBeenCalled()
|
|
|
|
dialogArgs = @dialog.showMessageBox.mostRecentCall.args[1]
|
|
|
|
expect(dialogArgs.buttons).toEqual ['Edit Message']
|
|
|
|
|
|
|
|
it "shows a warning if there's no subject", ->
|
|
|
|
useDraft.call @, to: [u1], subject: ""
|
|
|
|
makeComposer.call(@)
|
|
|
|
@composer._sendDraft()
|
|
|
|
expect(Actions.sendDraft).not.toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).toHaveBeenCalled()
|
|
|
|
dialogArgs = @dialog.showMessageBox.mostRecentCall.args[1]
|
|
|
|
expect(dialogArgs.buttons).toEqual ['Cancel', 'Send Anyway']
|
|
|
|
|
|
|
|
it "doesn't show a warning if requirements are satisfied", ->
|
|
|
|
useFullDraft.apply(@); makeComposer.call(@)
|
|
|
|
@composer._sendDraft()
|
|
|
|
expect(Actions.sendDraft).toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).not.toHaveBeenCalled()
|
|
|
|
|
|
|
|
describe "Checking for attachments", ->
|
|
|
|
warn = (body) ->
|
|
|
|
useDraft.call @, subject: "Subject", to: [u1], body: body
|
|
|
|
makeComposer.call(@); @composer._sendDraft()
|
|
|
|
expect(Actions.sendDraft).not.toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).toHaveBeenCalled()
|
|
|
|
dialogArgs = @dialog.showMessageBox.mostRecentCall.args[1]
|
|
|
|
expect(dialogArgs.buttons).toEqual ['Cancel', 'Send Anyway']
|
|
|
|
|
|
|
|
noWarn = (body) ->
|
2015-03-14 03:55:52 +08:00
|
|
|
useDraft.call @, subject: "Subject", to: [u1], body: body
|
2015-03-13 05:48:56 +08:00
|
|
|
makeComposer.call(@); @composer._sendDraft()
|
|
|
|
expect(Actions.sendDraft).toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).not.toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "warns", -> warn.call(@, "Check out the attached file")
|
|
|
|
it "warns", -> warn.call(@, "I've added an attachment")
|
|
|
|
it "warns", -> warn.call(@, "I'm going to attach the file")
|
2015-03-14 03:55:52 +08:00
|
|
|
it "warns", -> warn.call(@, "Hey attach me <div class='gmail_quote'>sup</div>")
|
2015-03-13 05:48:56 +08:00
|
|
|
|
|
|
|
it "doesn't warn", -> noWarn.call(@, "sup yo")
|
|
|
|
it "doesn't warn", -> noWarn.call(@, "Look at the file")
|
2015-03-14 03:55:52 +08:00
|
|
|
it "doesn't warn", -> noWarn.call(@, "Hey there <div class='gmail_quote'>attach</div>")
|
2015-03-13 05:48:56 +08:00
|
|
|
|
|
|
|
it "doesn't show a warning if you've attached a file", ->
|
|
|
|
useDraft.call @,
|
|
|
|
subject: "Subject"
|
|
|
|
to: [u1]
|
|
|
|
body: "Check out attached file"
|
|
|
|
files: [{filename:"abc"}]
|
|
|
|
makeComposer.call(@); @composer._sendDraft()
|
|
|
|
expect(Actions.sendDraft).toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).not.toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "bypasses the warning if force bit is set", ->
|
|
|
|
useDraft.call @, to: [u1], subject: ""
|
|
|
|
makeComposer.call(@)
|
|
|
|
@composer._sendDraft(force: true)
|
|
|
|
expect(Actions.sendDraft).toHaveBeenCalled()
|
|
|
|
expect(@dialog.showMessageBox).not.toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "sends when you click the send button", ->
|
|
|
|
useFullDraft.apply(@); makeComposer.call(@)
|
2015-04-25 02:33:10 +08:00
|
|
|
sendBtn = React.findDOMNode(@composer.refs.sendButton)
|
2015-03-13 05:48:56 +08:00
|
|
|
ReactTestUtils.Simulate.click sendBtn
|
|
|
|
expect(Actions.sendDraft).toHaveBeenCalledWith(DRAFT_LOCAL_ID)
|
|
|
|
expect(Actions.sendDraft.calls.length).toBe 1
|
|
|
|
|
|
|
|
simulateDraftStore = ->
|
|
|
|
DraftStore._sendingState[DRAFT_LOCAL_ID] = true
|
|
|
|
DraftStore.trigger()
|
|
|
|
|
|
|
|
it "doesn't send twice if you double click", ->
|
|
|
|
useFullDraft.apply(@); makeComposer.call(@)
|
2015-04-25 02:33:10 +08:00
|
|
|
sendBtn = React.findDOMNode(@composer.refs.sendButton)
|
2015-03-13 05:48:56 +08:00
|
|
|
ReactTestUtils.Simulate.click sendBtn
|
|
|
|
simulateDraftStore()
|
|
|
|
ReactTestUtils.Simulate.click sendBtn
|
|
|
|
expect(Actions.sendDraft).toHaveBeenCalledWith(DRAFT_LOCAL_ID)
|
|
|
|
expect(Actions.sendDraft.calls.length).toBe 1
|
|
|
|
|
|
|
|
it "disables the composer once sending has started", ->
|
|
|
|
useFullDraft.apply(@); makeComposer.call(@)
|
2015-04-25 02:33:10 +08:00
|
|
|
sendBtn = React.findDOMNode(@composer.refs.sendButton)
|
2015-03-13 05:48:56 +08:00
|
|
|
cover = ReactTestUtils.findRenderedDOMComponentWithClass(@composer, "composer-cover")
|
2015-04-25 02:33:10 +08:00
|
|
|
expect(React.findDOMNode(cover).style.display).toBe "none"
|
2015-03-13 05:48:56 +08:00
|
|
|
ReactTestUtils.Simulate.click sendBtn
|
|
|
|
simulateDraftStore()
|
2015-04-25 02:33:10 +08:00
|
|
|
expect(React.findDOMNode(cover).style.display).toBe "block"
|
2015-03-13 05:48:56 +08:00
|
|
|
expect(@composer.state.isSending).toBe true
|
|
|
|
|
|
|
|
it "re-enables the composer if sending threw an error", ->
|
|
|
|
useFullDraft.apply(@); makeComposer.call(@)
|
2015-04-25 02:33:10 +08:00
|
|
|
sendBtn = React.findDOMNode(@composer.refs.sendButton)
|
2015-03-13 05:48:56 +08:00
|
|
|
ReactTestUtils.Simulate.click sendBtn
|
|
|
|
simulateDraftStore()
|
|
|
|
expect(@composer.state.isSending).toBe true
|
|
|
|
Actions.sendDraftError("oh no")
|
|
|
|
DraftStore._sendingState[DRAFT_LOCAL_ID] = false
|
|
|
|
DraftStore.trigger()
|
|
|
|
expect(@composer.state.isSending).toBe false
|
|
|
|
|
|
|
|
describe "when sending a message with keyboard inputs", ->
|
|
|
|
beforeEach ->
|
|
|
|
useFullDraft.apply(@)
|
|
|
|
makeComposer.call(@)
|
|
|
|
spyOn(@composer, "_sendDraft")
|
|
|
|
InboxTestUtils.loadKeymap "internal_packages/composer/keymaps/composer.cson"
|
|
|
|
|
|
|
|
it "sends the draft on cmd-enter", ->
|
2015-04-25 02:33:10 +08:00
|
|
|
InboxTestUtils.keyPress("cmd-enter", React.findDOMNode(@composer))
|
2015-03-13 05:48:56 +08:00
|
|
|
expect(@composer._sendDraft).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "does not send the draft on enter if the button isn't in focus", ->
|
2015-04-25 02:33:10 +08:00
|
|
|
InboxTestUtils.keyPress("enter", React.findDOMNode(@composer))
|
2015-03-13 05:48:56 +08:00
|
|
|
expect(@composer._sendDraft).not.toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "sends the draft on enter when the button is in focus", ->
|
|
|
|
sendBtn = ReactTestUtils.findRenderedDOMComponentWithClass(@composer, "btn-send")
|
2015-04-25 02:33:10 +08:00
|
|
|
InboxTestUtils.keyPress("enter", React.findDOMNode(sendBtn))
|
2015-03-13 05:48:56 +08:00
|
|
|
expect(@composer._sendDraft).toHaveBeenCalled()
|
|
|
|
|
|
|
|
it "doesn't let you send twice", ->
|
|
|
|
sendBtn = ReactTestUtils.findRenderedDOMComponentWithClass(@composer, "btn-send")
|
2015-04-25 02:33:10 +08:00
|
|
|
InboxTestUtils.keyPress("enter", React.findDOMNode(sendBtn))
|
2015-03-13 05:48:56 +08:00
|
|
|
expect(@composer._sendDraft).toHaveBeenCalled()
|
|
|
|
|
|
|
|
|
|
|
|
describe "When composing a new message", ->
|
|
|
|
it "Can add someone in the to 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
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
it "Can add someone in the cc 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
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
it "Can add someone in the bcc 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
|
|
|
|
2015-03-13 05:48:56 +08:00
|
|
|
describe "When replying to a message", ->
|
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-13 05:48:56 +08:00
|
|
|
describe "When replying all to a message", ->
|
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-13 05:48:56 +08:00
|
|
|
describe "When forwarding a message", ->
|
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-13 05:48:56 +08:00
|
|
|
describe "When changing the subject of a message", ->
|