Mailspring/packages/client-app/spec/models
Halla Moore 73e990fc05 [client-app] Don't show non-existent children on folder creation
Summary:
Previously, after creating a new folder, the UI would indicate that the new
folder had children, even though it didn't. This was caused by duplicate models
in our `MutableQueryResultSet` for the user's categories. Basically, we would
sync the server version of the folder before the `SyncbackTask` for the new
folder returned its `serverId`. Without the `serverId`, the synced version of
the folder couldn't yet be tied to the optimistic folder, so a second row was
created in the database. This second row is removed when the `syncbackTask`
does return the `serverId`, because we persist the optimistic folder with a
`REPLACE INTO` query. (This deletes other rows with the same id.) However,
since this was done inside a `persist` change with the `serverId` and no
`unpersist` was ever recorded for the `clientId`, our `MutableQueryResultSet`
never removed the `clientId` model.

To address this, this diff adds a check in `updateModel` to see if the
`serverId` is being added. If it is, and both the `serverId` and `clientId`
exist in the `_ids` list, we remove the `clientId`.

The children indicator does still briefly show up while there are still two
separate rows for that folder in the database. If we want to get rid of this
completely, we would have to ensure that we do not sync the folder before the
`syncbackTask` returns the `serverId`. However, this would probably be pretty
involved, and for not much gain. This fix is much simpler and reduces most of
the issue.

Test Plan: manual

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4228
2017-03-16 12:26:42 -07:00
..
category-spec.coffee [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
contact-spec.coffee [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
event-spec.coffee [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
file-spec.coffee [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
message-spec.coffee [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
model-spec.es6 [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
model-with-metadata-spec.es6 [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
mutable-query-result-set-spec.es6 [client-app] Don't show non-existent children on folder creation 2017-03-16 12:26:42 -07:00
query-range-spec.es6 [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
query-spec.es6 [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
query-subscription-pool-spec.es6 [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
query-subscription-spec.es6 [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
thread-spec.coffee [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00