Mailspring/spec-nylas/tasks
Evan Morikawa 395bd80da2 fix(draft-list): draft list removes draft when the message sends
Summary:
This started when I noticed that drafts weren't dissapearing from the
draft list after send. This was a pretty big bug because if you ever
clicked on one again and tried to re-send it would throw a 400 error
saying the draft id doesn't exist.

This uncovered a few fundamental issues with the DB.

First of all, the reason the draft list wasn't updating was because the DB
trigger that happened when we got in a new message, was being ignored
since the diff contained no drafts (it's now a message).

The bigger issue was that if you had a draft with only a clientId, gave it
a serverId, and tried to call "save", the REPLACE INTO method would not
update the old object, but rather create a second duplicate. This is
because the `id` field was being used as the PRIMARY KEY, and in this
case, that `id` field changed! The fix was to change the PRIMARY KEY to be
the `cilent_id` instead of the `id` and use that as the REPLACE INTO
index.

We still need the `id` field; however, because all of our reads depend on
that field usually being the serverId

Fixes T3507

Test Plan: See new and updated tests

Reviewers: dillon, bengotow

Reviewed By: bengotow

Maniphest Tasks: T3507

Differential Revision: https://phab.nylas.com/D1992
2015-09-08 13:11:34 -07:00
..
change-folder-task-spec.coffee perf(*): Add indexes, optimize "shouldAcceptModel", optimize Tasks 2015-08-05 15:53:08 -07:00
change-labels-task-spec.coffee perf(*): Add indexes, optimize "shouldAcceptModel", optimize Tasks 2015-08-05 15:53:08 -07:00
change-mail-task-spec.coffee feat(draft): drafts that fail to send throw better errors 2015-09-03 16:29:33 -07:00
change-starred-task-spec.coffee perf(*): Add indexes, optimize "shouldAcceptModel", optimize Tasks 2015-08-05 15:53:08 -07:00
change-unread-task-spec.coffee perf(*): Add indexes, optimize "shouldAcceptModel", optimize Tasks 2015-08-05 15:53:08 -07:00
event-rsvp-spec.coffee refactor(db): change ID system to have clientIDs and serverIDs 2015-08-28 11:24:29 -07:00
file-upload-task-spec.coffee feat(draft): drafts that fail to send throw better errors 2015-09-03 16:29:33 -07:00
mark-message-read-spec.coffee feat(accounts): Kill namespaces, long live accounts 2015-08-21 15:29:58 -07:00
send-draft-spec.coffee fix(draft-list): draft list removes draft when the message sends 2015-09-08 13:11:34 -07:00
syncback-draft-spec.coffee fix(specs): Future specs should stub DatabaseStore.run, not find/findBy 2015-08-28 12:41:56 -07:00
task-spec.coffee feat(offline-mode, undo-redo): Tasks handle network errors better and retry, undo/redo based on tasks 2015-07-07 13:38:53 -04:00