Mailspring/packages/client-sync
Juan Tejada 3554fb2510 [client-app] Fix passing cursor to delta streams
Summary:
Currently, when we auth an account for the first time in Nylas Mail (or
we blow away the database), the app is going to request transactions
since cursor `null` from the /delta/streaming endpoint and from the local-sync
delta observable, instead of requesting transactions since cursor `0`

This is due to a subtle bug with the use of default values when
destructuring an object. Our coded did the following:
```
const {cursor = 0} = this._state
```
Which at a glance seems correct. However, this will only work as
expected if `this._state` has the following shape:
```
{cursor: undefined}
```
And unfortunately, our `this._state` looked like this when authing an
account for the first time:
```
{cursor: null}
```

Which would make `cursor === null` instead of `0`.
This is because when using default values, null is considered an
intentional argument/value, as opposed to not passing any argument/value
(which will mean that the argument is undefined).

This was a regression introduced in d60a23c and 8bc2ec5

Test Plan: manual, will add regression test in upcoming diff

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4243
2017-03-20 16:16:46 -07:00
..
images [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
spec Revert "Revert "[feat] Add support for send later"" 2017-03-07 17:21:29 -08:00
src [client-app] Fix passing cursor to delta streams 2017-03-20 16:16:46 -07:00
stylesheets [client-*] Rename packages folders and update readme 2017-02-16 13:31:37 -08:00
main.es6 [client-sync] Shim sequelize to timeout after 1 minute 2017-03-10 13:39:27 -08:00
package.json [*] move to monorepo 2017-02-16 18:46:26 -08:00
README.md [*] update and add READMEs to each package 2017-02-17 17:28:09 -08:00

Client Sync

This is the mail sync engine that runs within the Nylas Mail client

It is symlinked in as an internal_package of Nylas Mail via the postinstall script of the root repo.

Important Usage Notes:

Since this is symlinked in as an internal_package of Nylas Mail, there are a handulf of considerations when developing in client-sync. Some common gotchas:

  • You MAY use NylasEnv, NylasExports and other injected libraries in the Nylas Mail client environment.
  • You MAY use any 3rd party library declared in client-app/package.json. Since this gets added as a plugin of the Nylas Mail client, you'll have access to all libraries. This works because the client-app/node_modules was added to the global require paths. That lets us access client-app plugins without being a file directory decendent of client-app (client-sync is now a sibling of client-app)
  • You may NOT add "dependencies" to the client-sync/package.json. If you need a 3rd party library, add it to the main client-app/package.json. All Nylas Mail plugins (those inside of internal_packages), may no longer declare their own dependencies.
  • You should be aggressive at moving generic mail methods to isomorphic-core. We may eventually want to make large chunks of client-sync work in a cloud environment as well.