mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-03-03 19:43:04 +08:00
fix(draft): saves silently resolve if draft can't be found
This commit is contained in:
parent
551ced639e
commit
bb7909f379
2 changed files with 9 additions and 2 deletions
|
@ -67,6 +67,12 @@ describe "SaveDraftTask", ->
|
|||
newBody = DatabaseStore.persistModel.calls[0].args[0].body
|
||||
expect(newBody).toBe "test body"
|
||||
|
||||
it "does nothing if no draft can be found in the db", ->
|
||||
task = new SaveDraftTask("missingDraftId")
|
||||
waitsForPromise =>
|
||||
task.performLocal().then ->
|
||||
expect(DatabaseStore.persistModel).not.toHaveBeenCalled()
|
||||
|
||||
describe "performRemote", ->
|
||||
beforeEach ->
|
||||
spyOn(atom.inbox, 'makeRequest').andCallFake (opts) ->
|
||||
|
|
|
@ -35,8 +35,9 @@ class SaveDraftTask extends Task
|
|||
|
||||
DatabaseStore.findByLocalId(Message, @draftLocalId).then (draft) =>
|
||||
if not draft?
|
||||
errMsg = "Cannot persist changes to non-existent draft #{@draftLocalId}"
|
||||
reject(new Error(errMsg))
|
||||
# This can happen if a save draft task is queued after it has been
|
||||
# destroyed. Nothing we can really do about it, so ignore this.
|
||||
resolve()
|
||||
else if _.size(@changes) is 0
|
||||
resolve()
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue