Summary:
Previously, if a draft was deleted while a DraftChangeSet had uncommitted changes, it would blow up trying to find the draft.
This is bad, and can happen in normal scenarios. There are several changes in this diff:
- The DraftChangeSet no longer retrieves the draft from the database before saving changes. Instead, the save logic is in the DraftStoreProxy which already has a version of the draft kept fresh by a subscription to the DraftStore.
- The SyncbackDraftTask already had logic for POSTing when a PUT to a draft returns a 404, so no new logic was necessary there. THe new "commit" logic causes us to put back the draft that was lost, and then when we save it we detatch it from it's serverId and re-save.
In manual testing, this transparently handles the case where you delete a draft from Gmail while editing it.
Test Plan: I've added 22 tests for the DraftChangeSet and DraftStoreProxy
Reviewers: dillon, evan
Reviewed By: dillon, evan
Differential Revision: https://phab.nylas.com/D2012