mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-09 12:51:50 +08:00
fix(draft): fix showing of incorrect body when pending send
Summary: Fixes T3712 Test Plan: new tests Reviewers: juan, bengotow Reviewed By: bengotow Maniphest Tasks: T3712 Differential Revision: https://phab.nylas.com/D2273
This commit is contained in:
parent
f8539aa382
commit
0c93cb856f
5 changed files with 42 additions and 2 deletions
|
@ -24,6 +24,10 @@ class MessageItemBody extends React.Component
|
||||||
componentWillMount: =>
|
componentWillMount: =>
|
||||||
@_unsub = MessageBodyProcessor.processAndSubscribe(@props.message, @_onBodyChanged)
|
@_unsub = MessageBodyProcessor.processAndSubscribe(@props.message, @_onBodyChanged)
|
||||||
|
|
||||||
|
componentWillReceiveProps: (newProps) =>
|
||||||
|
@_unsub?()
|
||||||
|
@_unsub = MessageBodyProcessor.processAndSubscribe(newProps.message, @_onBodyChanged)
|
||||||
|
|
||||||
componentWillUnmount: =>
|
componentWillUnmount: =>
|
||||||
@_unsub?()
|
@_unsub?()
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,10 @@
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.item {
|
||||||
|
overflow-x: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
&.curl-history {
|
&.curl-history {
|
||||||
.item {
|
.item {
|
||||||
|
|
|
@ -720,7 +720,29 @@ describe "DraftStore", ->
|
||||||
Actions.queueTask.calls.length > 0
|
Actions.queueTask.calls.length > 0
|
||||||
runs ->
|
runs ->
|
||||||
expect(DraftStore.isSendingDraft(draftClientId)).toBe true
|
expect(DraftStore.isSendingDraft(draftClientId)).toBe true
|
||||||
|
|
||||||
|
# Since all changes haven't been applied yet, we want to ensure that
|
||||||
|
# no view of the draft renders the draft as if its sending, but with
|
||||||
|
# the wrong text.
|
||||||
|
it "does NOT trigger until the latest changes have been applied", ->
|
||||||
|
spyOn(NylasEnv, "isMainWindow").andReturn true
|
||||||
|
spyOn(Actions, "queueTask").andCallThrough()
|
||||||
|
runs ->
|
||||||
|
DraftStore._onSendDraft(draftClientId)
|
||||||
|
expect(DraftStore.trigger).not.toHaveBeenCalled()
|
||||||
|
waitsFor ->
|
||||||
|
Actions.queueTask.calls.length > 0
|
||||||
|
runs ->
|
||||||
|
# Normally, the session.changes.commit will persist to the
|
||||||
|
# Database. Since that's stubbed out, we need to manually invoke
|
||||||
|
# to database update event to get the trigger (which we want to
|
||||||
|
# test) to fire
|
||||||
|
DraftStore._onDataChanged
|
||||||
|
objectClass: "Message"
|
||||||
|
objects: [draft: true]
|
||||||
|
expect(DraftStore.isSendingDraft(draftClientId)).toBe true
|
||||||
expect(DraftStore.trigger).toHaveBeenCalled()
|
expect(DraftStore.trigger).toHaveBeenCalled()
|
||||||
|
expect(DraftStore.trigger.calls.length).toBe 1
|
||||||
|
|
||||||
it "returns false if the draft hasn't been seen", ->
|
it "returns false if the draft hasn't been seen", ->
|
||||||
spyOn(NylasEnv, "isMainWindow").andReturn true
|
spyOn(NylasEnv, "isMainWindow").andReturn true
|
||||||
|
|
|
@ -486,7 +486,11 @@ class DraftStore
|
||||||
SoundRegistry.playSound('hit-send')
|
SoundRegistry.playSound('hit-send')
|
||||||
|
|
||||||
@_draftsSending[draftClientId] = true
|
@_draftsSending[draftClientId] = true
|
||||||
@trigger(draftClientId)
|
|
||||||
|
# It's important NOT to call `trigger(draftClientId)` here. At this
|
||||||
|
# point there are still unpersisted changes in the DraftStoreProxy. If
|
||||||
|
# we `trigger`, we'll briefly display the wrong version of the draft
|
||||||
|
# as if it was sending.
|
||||||
|
|
||||||
@sessionForClientId(draftClientId).then (session) =>
|
@sessionForClientId(draftClientId).then (session) =>
|
||||||
@_runExtensionsBeforeSend(session)
|
@_runExtensionsBeforeSend(session)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
crypto = require "crypto"
|
||||||
MessageUtils = require '../models/message-utils'
|
MessageUtils = require '../models/message-utils'
|
||||||
MessageStore = require './message-store'
|
MessageStore = require './message-store'
|
||||||
|
|
||||||
|
@ -17,8 +18,13 @@ class MessageBodyProcessor
|
||||||
for {message, callback} in @_subscriptions
|
for {message, callback} in @_subscriptions
|
||||||
callback(@process(message))
|
callback(@process(message))
|
||||||
|
|
||||||
|
# It's far safer to key off the hash of the body then the [id, version]
|
||||||
|
# pair. This is because it's theoretically possible for the body to
|
||||||
|
# change without the version updating. When drafts sent N1 used to
|
||||||
|
# optimistically display the message before the latest changes
|
||||||
|
# persisted.
|
||||||
_key: (message) ->
|
_key: (message) ->
|
||||||
return message.id + message.version
|
return crypto.createHash('md5').update(message.body).digest('hex')
|
||||||
|
|
||||||
version: ->
|
version: ->
|
||||||
@_version
|
@_version
|
||||||
|
|
Loading…
Add table
Reference in a new issue