mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-24 08:04:11 +08:00
Merge branch 'master' of github.com:nylas/N1
This commit is contained in:
commit
00d0518dbf
2 changed files with 14 additions and 2 deletions
|
@ -28,7 +28,7 @@ testData =
|
||||||
body: '<body>123</body>'
|
body: '<body>123</body>'
|
||||||
|
|
||||||
localDraft = -> new Message _.extend {}, testData, {clientId: "local-id"}
|
localDraft = -> new Message _.extend {}, testData, {clientId: "local-id"}
|
||||||
remoteDraft = -> new Message _.extend {}, testData, {clientId: "local-id", serverId: "remoteid1234"}
|
remoteDraft = -> new Message _.extend {}, testData, {clientId: "local-id", serverId: "remoteid1234", threadId: '1234', version: 2}
|
||||||
|
|
||||||
describe "SyncbackDraftTask", ->
|
describe "SyncbackDraftTask", ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -141,6 +141,17 @@ describe "SyncbackDraftTask", ->
|
||||||
expect(options.accountId).toBe("abc123")
|
expect(options.accountId).toBe("abc123")
|
||||||
expect(options.method).toBe('POST')
|
expect(options.method).toBe('POST')
|
||||||
|
|
||||||
|
it "should apply the server ID, thread ID and version to the draft", ->
|
||||||
|
task = new SyncbackDraftTask("localDraftId")
|
||||||
|
waitsForPromise =>
|
||||||
|
task.performRemote().then ->
|
||||||
|
expect(DatabaseTransaction.prototype.persistModel).toHaveBeenCalled()
|
||||||
|
saved = DatabaseTransaction.prototype.persistModel.calls[0].args[0]
|
||||||
|
remote = remoteDraft()
|
||||||
|
expect(saved.threadId).toEqual(remote.threadId)
|
||||||
|
expect(saved.serverId).toEqual(remote.serverId)
|
||||||
|
expect(saved.version).toEqual(remote.version)
|
||||||
|
|
||||||
it "should pass returnsModel:false so that the draft can be manually removed/added to the database, accounting for its ID change", ->
|
it "should pass returnsModel:false so that the draft can be manually removed/added to the database, accounting for its ID change", ->
|
||||||
task = new SyncbackDraftTask("localDraftId")
|
task = new SyncbackDraftTask("localDraftId")
|
||||||
waitsForPromise =>
|
waitsForPromise =>
|
||||||
|
|
|
@ -67,7 +67,7 @@ class SyncbackDraftTask extends Task
|
||||||
body: draft.toJSON()
|
body: draft.toJSON()
|
||||||
returnsModel: false
|
returnsModel: false
|
||||||
|
|
||||||
updateLocalDraft: ({version, id}) =>
|
updateLocalDraft: ({version, id, thread_id}) =>
|
||||||
# Important: There could be a significant delay between us initiating the save
|
# Important: There could be a significant delay between us initiating the save
|
||||||
# and getting JSON back from the server. Our local copy of the draft may have
|
# and getting JSON back from the server. Our local copy of the draft may have
|
||||||
# already changed more.
|
# already changed more.
|
||||||
|
@ -81,6 +81,7 @@ class SyncbackDraftTask extends Task
|
||||||
# Draft may have been deleted. Oh well.
|
# Draft may have been deleted. Oh well.
|
||||||
return Promise.resolve() unless draft
|
return Promise.resolve() unless draft
|
||||||
if draft.serverId isnt id
|
if draft.serverId isnt id
|
||||||
|
draft.threadId = thread_id
|
||||||
draft.serverId = id
|
draft.serverId = id
|
||||||
draftIsNew = true
|
draftIsNew = true
|
||||||
draft.version = version
|
draft.version = version
|
||||||
|
|
Loading…
Reference in a new issue