Commit graph

878 commits

Author SHA1 Message Date
Mark Hahnenberg 8d057ca256 [client-sync] Refactor GmailSearchClient to use X-GM-RAW
Summary:
Previously we used the Gmail REST API to get search results. This API
returns the X-GM-MSGID which is different from the folder UID. Gmail also
offers the X-GM-RAW extension for IMAP's UID SEARCH command which allows
us to pass through the raw search query. This enables us to vastly
simplify the GmailSearchClient by having it subclass ImapSearchClient
and override a few select methods. Yay!

Test Plan: Run locally, verify that Gmail search queries still work

Reviewers: evan, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D4094
2017-03-02 17:27:07 -08:00
Mark Hahnenberg 9ec7b57f9a [client-app] Add proper IMAP search backend
Summary:
Previously for IMAP we just grabbed the search text and fed it into a TEXT
query. Now we have a proper backend that generates the appropriate
search criteria according to the IMAP spec. Important to note that we
don't support 'in:' yet, which is complicated due to the way that IMAP
search is scoped to the currently selected folder.

Test Plan: Run tests, run locally and verify IMAP search still works.

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4071
2017-03-02 14:50:35 -08:00
Juan Tejada 6557618cb4 [iso-core] 🎨 Rename imap-pool.es6 to imap-connection-pool
To be consistent with the name of the exported module
2017-03-02 14:45:34 -08:00
Juan Tejada 04fab196f2 bump(version) 1.0.31 2017-03-02 12:10:50 -08:00
Halla Moore be805f7b5a [client-app, client-private-plugins] Update the pending send-reminders UI
Summary:
- Add an icon to threads that have reminders set
- Show the pending reminder message header in all perspectives, rather than
    just the Reminders perspective
- Add the ability to clear the reminder from the message header
- Condense the message header text

Test Plan: manual

Reviewers: evan, juan

Reviewed By: evan, juan

Subscribers: sdw

Differential Revision: https://phab.nylas.com/D4052
2017-03-02 09:52:30 -08:00
Juan Tejada 0cf6027482 [iso-core] Fix IMAPConnection.openBox
Set _isOpeningBox to true at the right moment
2017-03-01 17:19:21 -08:00
Juan Tejada df96678470 [client-sync] 🎨 lint errors 2017-03-01 15:48:16 -08:00
Juan Tejada 830b300ebc [cloud-*] (imap) 🎨 Fixup imap settings resolution in gmail auth
Summary: `generateXOAuth2Token` seems to be better placed inside gmail-oauth-helpers

Test Plan: none :(

Reviewers: khamidou, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D4048
2017-03-01 15:27:21 -08:00
Juan Tejada 3a626988c8 [iso-core] Protect from operating on IMAP connection while opening a box
Summary: See title

Test Plan: manual

Reviewers: spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4072
2017-03-01 15:25:10 -08:00
Juan Tejada 1f45c58aad [client-app] Report 100% of search performed events
Summary:
Gleb mentioned that we need the sample size of search events to be
bigger, so let's report all search events

Test Plan: manual

Reviewers: evan, gleb, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4077
2017-03-01 14:56:25 -08:00
Juan Tejada 6cc8d0c997 [client-app] Correctly import nylas-api-helpers 2017-03-01 14:06:00 -08:00
Mark Hahnenberg eebdc295ef [client-sync] Scale sync batch size based on folder SELECT duration
Summary:
If it's expensive for us to SELECT a folder (which happens a lot for
large gmail accounts), we should try to sync more messages so that we
don't waste a ton of time SELECT-ing during initial sync. This speeds up
initial sync quite a bit.

Test Plan: Run locally, verify batches are properly computed

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4050
2017-03-01 12:24:58 -08:00
Evan Morikawa 53465515b0 [client-app] replace setImmediate with setTimeout as Promise scheduler
Summary:
This changes the scheduler from `setImmediate` to `setTimeout`. The HUGE
difference is that Chrome's async stack traces works with `setTimeout` but
does NOT work with `setImmediate`. These two functions are adjacent to
each other in the Node event loop, so nothing should depend on the change
in ordering.

Test Plan: manual

Reviewers: mark, spang, halla, juan

Reviewed By: spang, halla

Differential Revision: https://phab.nylas.com/D4068
2017-03-01 12:16:54 -08:00
Evan Morikawa 4de32d2828 [client-app] use new Bluebird preferred longStackTraces syntax
Summary: Bluebird changed the way you call `longStackTraces`. This uses the latest

Test Plan: manual

Reviewers: spang, halla, juan

Reviewed By: spang, halla

Differential Revision: https://phab.nylas.com/D4067
2017-03-01 12:15:46 -08:00
Evan Morikawa 756c80a7ce [client-app] remove unused async message body loading & returnsModel
Summary:
We no longer optimistically fetch messages when we load their bodies. We
always get the full message with bodies returned via the in memory delta
stream

Test Plan: manual

Reviewers: spang, halla, juan

Reviewed By: spang, halla, juan

Differential Revision: https://phab.nylas.com/D4066
2017-03-01 12:15:18 -08:00
Evan Morikawa ba1f429928 [client-app] deprecate returnsModel param for nylas-api-request
Summary:
We no longer need to use the `returnsModel` param since we get all of our
models through the in memory delta stream. There were a ton of places
unnecessarily passing `returnsModel: false` when it defaults to false in
the first place

Depends on D4057

Test Plan: manual

Reviewers: halla, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D4065
2017-03-01 12:13:08 -08:00
Evan Morikawa abaf63202c [client-app] deprecate ensureOnce for NylasAPI requests
Summary:
We no longer use the `ensureOnce` bit.

Depends on D4057

Test Plan: manual

Reviewers: spang, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4064
2017-03-01 12:12:28 -08:00
Evan Morikawa 65ae74d21e [client-app] deprecate beforeProcessing in nylas-api-request
Summary:
This removes the last reference to a now unused `beforeProcessing` feature
of the Nylas API Request.

Depends on D4057

Test Plan: manual

Reviewers: spang, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4063
2017-03-01 12:11:59 -08:00
Evan Morikawa fb94ff32f7 [client-app] have account store handle API auth errors
Summary:
The old  NylasAPIRequest helper class used to do all sorts of run-time
requiring to attempt to notify of auth errors when 401s and 403s came up
in a request. We now move that logic to the AccountStore where it belongs.

Depends on D4057

Test Plan: Manual

Reviewers: spang, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4060
2017-03-01 12:11:13 -08:00
Evan Morikawa 787e13a0d2 [client-app] refactor nylas-api-request
Summary:
This greatly refactors the NylasAPIRequest object to be more single
purpose, easier to read, async-ified.

It also fixes issues where long stack traces weren't being reported bcause
`reportError` was being called before the error had time to make it
through Bluebird's rejection handler (which adds back in the long stack
traces).

This also fixes an issue where ignorable errors (like 404s,
ESOCKETTIMEDOUT) were being reporting to Sentry.

This also fixes subtle conditions where the request run would throw mixed
error types (sometimes regular `Error`s, sometimes `APIError`s).

The old class used to handle logging people out on 401s. This is now moved
to the AccountStore in a different diff.

We've also deprecated the `returnsModel` param in a separate diff.

This deprecates the `PriorityUICoordinator` since we no longer need to
worry about frequently making expensive API requests to pull down data
like we used to in the old cloud-based API.

This deprecates `ensureOnce` param in a separate diff.

Test Plan:
Manually boot app. Check regular 404s don't throw. Check requests get
through. Check special ESOCKETTIMEDOUT type errors are properly handled

Reviewers: juan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4057
2017-03-01 12:10:38 -08:00
Mark Hahnenberg 2d2621d2f3 [client-app] Refactor search query codegen into proper backend
Summary:
Previously we were using the raw visitors that were confined to the flux
attributes directory. We're going to add more search query backends, so this
is mostly just moving things to a new, more general place.

Test Plan:
Run locally, verify parser specs still work, verify in-app search
still works.

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4053
2017-03-01 11:53:03 -08:00
Halla Moore 097a96274f [isomorphic-core] Make sure specs can run without electron
Summary:
Isomorphic-core should be functional outside of the client environment

Depends on D4056

Test Plan: Run the test suite

Reviewers: evan, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D4062
2017-03-01 11:10:41 -08:00
Halla Moore 82e7a276a3 [*] Move Jasmine setup into isomorphic-core
Summary:
Move the base Jasmine spec runner into isomorphic-core to prevent
code duplication. Jasmine will look for the config file relative to
the directory it's being run in though, so we need to symlink the
config file into each package that will need it.

Test Plan: Run tests once the suites are integrated

Reviewers: evan, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D4056
2017-03-01 11:08:37 -08:00
Halla Moore 953a8e438e [*] Run the isomorphic-core specs as part of the client test suite
Summary:
Convert the isomorphic-core specs to Jasmine 1 and symlink them into
client-app/internal_packages so they are run as part of the client
test suite.

Test Plan: Ran the suite with fdescribes in iso-core to ensure they were being called properly

Reviewers: evan, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D4055
2017-03-01 11:07:48 -08:00
Christine Spang 8c30697241 [client-sync] Enable logging in prod builds
Summary:
Disabling verbose logging in production builds just makes it harder to help our
users help us fix their problems.

Test Plan: run app without --dev

Reviewers: mark, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4070
2017-03-01 08:11:00 -08:00
Juan Tejada b6a1fc5234 [client-app] Fix measurement of thread-list action metrics
Summary:
We detect when a thread is removed from the thread-list by listening to
`Actions.threadListDidUpdate`. However, we were not firing the action at
the correct moment.

Before this commit, we fired the action on the root `ThreadList`'s
`componentDidUpdate`, however did this not actually fire when the
child list actually updated/removed threads from the list.

This sort of used to work because before 396a027bcb
the root ThreadList component re-rendered all the time, so it fired the
action, but after initial sync, we would never actually report any
thread-list action metrics at all

Test Plan: manual

Reviewers: spang, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4051
2017-02-28 14:07:52 -08:00
Juan Tejada d3381b7446 [client-app] Update changelog 2017-02-28 13:19:34 -08:00
Christine Spang 26d247bd97 [client-app] Actually fix send+archive
The previous fix only worked by coincidence. It turns out that we don't have
the right data to associate draftClientId with ChangeMailTask on task
creation, so we have to either look up this data inside the dependency
function or make the dependency check looser.

This check gets run all the time, so we chose to make the check looser
rather than putting a db call in here and changing the interface to support
an async version of isDependentOnTask().

This patch also makes it so that the fix works properly when Undo Send
is enabled.

Fixes T7889
2017-02-28 12:38:14 -08:00
Christine Spang 1d90f7f770 [client-app] Fix ChangeMailTask dependency on SendDraftTask
Because ChangeMailTask only depended on EnsureMessageInSentFolder task,
if a user sent a message & then archived it before the send completed,
the ChangeMailTask could run in between the SendDraftTask and
EnsureMessageInSentFolderTask and fail because it's
EnsureMessageInSentFolderTask that detects the new UID for the message.

Fixes T7889
2017-02-28 12:12:39 -08:00
Christine Spang 5d440c6b93 [client-sync] Fix wording in comment 2017-02-28 12:12:39 -08:00
Christine Spang 6e1dabadbb [client-sync] Add check for syncWorker to SyncbackTaskRunner 2017-02-28 12:12:39 -08:00
Juan Tejada 3f726d4d0b [client-app] Update changelog 2017-02-28 12:12:10 -08:00
Juan Tejada 19d504524b bump(version) 1.0.30 2017-02-28 11:48:28 -08:00
Juan Tejada bb76da14cc [client-app] Fix EnsureMessageInFolderTask - no need to get acct from imap connection 2017-02-28 11:26:58 -08:00
Juan Tejada 6cf9e487b0 [iso-core] Fix typo in IMAPBox 2017-02-28 11:16:37 -08:00
Evan Morikawa 9fd2f097b0 [client-sync] add assertion about Reference not cleaned up properly 2017-02-28 11:09:17 -08:00
Juan Tejada de0e30d8dd Revert "[client-app] Limit search to focused perspective"
Temporarily reverting this commit for 1.0.30 release.
See https://phab.nylas.com/T7910 for details
This reverts commit da6bc473f8.
2017-02-28 11:07:44 -08:00
Evan Morikawa 2126060d27 [iso-core] imap-connection properly resolves this 2017-02-28 10:57:29 -08:00
Evan Morikawa 875fac3227 [iso-core] imap-box.js -> imap-box.es6 2017-02-28 10:43:49 -08:00
Juan Tejada 0294db95cf Revert "[client-app] Properly re-index threads when their data has changed"
Temporarily reverting this commit for 1.0.30 release because it is causing
performance issues: https://phab.nylas.com/T7910

This reverts commit 5e35d39eb2.
2017-02-28 10:35:58 -08:00
Juan Tejada 5714a23501 [client-app] Remove contact support btn from red box
Summary: See title

Test Plan: manual

Reviewers: evan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4049
2017-02-28 10:27:58 -08:00
Juan Tejada 396a027bcb [client-app] Prevent unnecessary re-rendering of thread-list
Summary:
This commit adds a `shouldComponentUpdate` to thread-list.cjsx so that
the thread list doesn't unnecessarily /try/ to re-render when state or
props haven't actually changed.

I noticed this because the thread list was constantly calling `render`
even though it didn't render any changes to the DOM. This was caused
because it listens to `NylasSyncStatusStore` which constantly triggers,
even though the piece of state the list is interested in rarely changes,
causing unnecessary calls to the `render` loop.

Test Plan: manual

Reviewers: halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4047
2017-02-28 10:04:31 -08:00
Juan Tejada 1e7541a1ee [iso-core] Loosen checks for detecting retryable errors + add new one
Summary: see title

Test Plan: manual

Reviewers: evan, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4046
2017-02-28 10:00:12 -08:00
Juan Tejada 8ade5d6486 [iso-core] (imap-P3) Fixup IMAPConnection and IMAPBox
Summary:
This commit is an attempt to cleanup duplicated code and crufty code
inside IMAPConnection and IMAPBox

Specifically:
- It replaces `_createConnectionPromise` with a more aptly named (imo) `_withPreparedConnection` helper, which provides the user a node-imap connection that will correctly time out and handle `error` and `end` events. Most of these changes are just changing existing code to use the new interface.
- Adds a subtle change to how we handle `end` and `error` events on the connections. Previously, we manually called `this.end()` on `error`, but not on `end`. From what I could gather from the old comment documenting `_createConnectionPromise`, we should /also/ call `this.end()` on `end` because node-imap doesn't clean up correctly and can leave the connection hanging (taking care not to introduce a recursion loop by `end`ing on `end`). Additionally, it no longer listens to the events via `once` but via `on`, which should be okay given that the listeners get cleared at the end.

This /might/ fix some instances of sync freezing up (T7837).

Depends on D4035

Test Plan: manual -- this really needs some unit tests 😢

Reviewers: spang, halla, mark, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4036
2017-02-28 09:58:10 -08:00
Juan Tejada 18095cac3e [iso-core] (imap-P2) Actually fix constant socket timeout errors 😢
Summary:
Remember how we made it so imap socket timeouts would increment up to 10m if
we constantly got timeout errors? Remember how we told everyone in
https://github.com/nylas/nylas-mail/issues/3232 that we'd fixed their problems, but they weren't actually fixed?

Well, we weren't /actually/ applying the correct timeout value. 😢

Depends on D4033

Test Plan: manual

Reviewers: spang, halla, mark, evan

Reviewed By: mark, evan

Differential Revision: https://phab.nylas.com/D4035
2017-02-28 09:41:21 -08:00
Juan Tejada a2e0b81493 [iso-core] (imap-P1) 🎨 Fixup settings resolution in IMAPConnection
Summary:
The way it was set up was a little smelly.
- `this._settings` were /not/ the actual settings. Now, internally we have access to `this._resolvedSettings`
- `this.resolvedSettings` was being set kind of out of nowhere (gmail-oauth-helpers needs it, hence adding a getter instead)

Test Plan: manual

Reviewers: spang, mark, evan, halla

Reviewed By: mark, evan, halla

Subscribers: khamidou

Differential Revision: https://phab.nylas.com/D4033
2017-02-28 09:21:09 -08:00
Juan Tejada 72613baf5d [client-app] Fix selecting and creating signatures in preferences
Summary:
This commit fixes 2 issues with signatures in the preferences:
- Creating a signature (via any of the create buttons) would create 2 signatures
- Trying to select accounts to associate with a signature in the preferences would not work (the account would not be selected)

This was a regression introduced in e638e94084 (diff-4f38fd25aa24b48a309354be643165d3R26)

3111c16 made it so we attempt to `activate` any Stores that are registered with
the StoreRegistry. When adding stores to `nylas-exports`, they are
automatically registered in the StoreRegistry. Given that the
`SignatureStore` is in `nylas-exports`, and consequently is registered in
the StoreRegistry, it would be `activate`d upon window boot.

However, we were also manually activating it inside `internal_packages/composer-signatures/lib/main.es6`.
This caused it to register listeners for every action **twice**. For
this reason, 2 signatures would be created when trying to create 1, and
an account would be immediately unselected after being selected int he
signatures dropdown in preferences.

(Other changes in this are just stylistic)

Test Plan: manual

Reviewers: spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4043
2017-02-28 09:14:28 -08:00
Juan Tejada de9484cc52 [client-sync] Fix missing pass in of syncWorker in EnsureMessageInSentFolder 2017-02-26 10:36:31 -08:00
Mark Hahnenberg 6bd6242398 [client-sync] Use IMAPConnectionPool in client sync worker
Summary: See title

Test Plan: Run locally, make sure sync still works

Reviewers: evan, spang, juan

Reviewed By: spang, juan

Differential Revision: https://phab.nylas.com/D3998
2017-02-24 13:09:32 -08:00
Christine Spang e991349708 [client-sync] Fix missing pass in of syncWorker to FetchNewMessagesInFolder 2017-02-24 12:49:37 -08:00