Commit graph

259 commits

Author SHA1 Message Date
Juan Tejada c118c99d73 fix(sent): Do not allow sent or drafts to be modified
- Specifically, when dragging from the sent perspective, we should not
  allow the sent label to be removed.
- If moved to trash or spam, `all mail` will be correctly removed from
  the thread, but it will keep sent label
- Show sent MailLabel on the threads
2016-03-10 15:44:53 -08:00
Juan Tejada f12896d54f fix(gmail-labels): Constraint so threads always belong to all,spam or trash
Summary:
- In Gmail all threads /must/ belong to either All Mail, Trash and Spam, and
  they are mutually exclusive, so we need to make sure that any add/remove
  label operation still guarantees that constraint
- Update ChangeLabelsTask to modify the set of labels to add and remove
  based on this rule
- Update tasksFor archiving, moving to trash and moving to spam so they
  don't affect any other labels in the thread, as gmail does.
- Removing from view /will/ remove any current labels, but will also
  move between all mail and trash as needed
- Remove Inbox, Trash and Spam from the CategoryPicker, as Gmail does

Test Plan: - Unit tests

Reviewers: drew, evan, bengotow

Reviewed By: drew, evan, bengotow

Differential Revision: https://phab.nylas.com/D2715
2016-03-10 14:13:31 -08:00
Ben Gotow 3076acd7af fix(trash/spam): New inAllMail filter applied to all mailbox views except trash and spam 2016-03-10 12:41:32 -08:00
Ben Gotow 2bd03dc44f fix(sync): Pull down and associate metadata during initial sync
Summary:
Snooze should wait for categories on all accounts

Fix authPlugin to rembmer `plugin+accountId`, not pluginId, add specs

categories() returned [], categories(acctId) returned {}

dry up sync worker, fetch metadata before anything else

Test Plan: Run tests

Reviewers: drew, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2693
2016-03-10 11:06:06 -08:00
Ben Gotow 4fefec0b52 patch(save): Only save drafts when necessary, avoid sync-engine issues
Summary:
Previously, we have saved drafts back to the user's provider through the sync engine. There are a handful of very serious edge case issues we're working to solve that are creating a bad user experience. (#933, #1175, #1504, #1237)

For now, we're going to change the behavior of N1 to mitagate these issues.

- If you create a draft in N1, we will not sync it to other mail clients while you're working on it.
- If you enable send later, we'll start syncing the draft to the server as before.
- If you created the draft in another client, we'll sync the draft to the server as before.

Fix specs

Test Plan: Run specs

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2706
2016-03-10 11:03:38 -08:00
Ben Gotow 7a31da9fc9 fix(bodies): Move loading into component, add retry, loading spinner 2016-03-09 19:14:54 -08:00
Juan Tejada c6acca8ca3 remove(popover): Remove Popover in favor of FixedPopover
Summary:
- FixedPopover now correctly adjusts itself when overflowing outside
  window, in all directions
  - Updates styles
  - Adds specs
- Remove Popover and popover.less, and refactor all code that used it in
  favor of the new FixedPopover

Test Plan: Unit tests

Reviewers: drew, evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2697
2016-03-09 10:05:46 -08:00
Evan Morikawa 6cb2791642 fix(spec): fix nylas api specs 2016-03-09 10:03:05 -05:00
Ben Gotow f2762a9472 fix(downloads): Properly handle network errors, retries of downloads 2016-03-08 18:32:47 -08:00
Ben Gotow eec5edce4d fix(launch): Do not create global symlinks to N1 and apm. Closes #1553 2016-03-08 10:34:12 -08:00
Evan Morikawa 388fd455ea fix(lint): fix linter issues 2016-03-08 13:02:10 -05:00
Drew Regitsky e35b37441b fix(send): make send/syncback draft tasks cooperate, fix task ordering tracking
Summary:
Fixes an issue with sending where certain conditions could result in a
duplicated message.

Fixes task dependency logic for draft syncback and send. Changes `createdAt`
on tasks to instead be `sequentialId`, assigned when the task is queued, to
track order of enqueueing. Renames `isDependentTask` => `isDependentOnTask`
and adds comments for clarity.

Test Plan:
Specs updated. Might be good to add some later to test this particular
edge case.

Reviewers: juan, evan, bengotow

Reviewed By: evan, bengotow

Differential Revision: https://phab.nylas.com/D2681
2016-03-07 20:14:58 -08:00
Juan Tejada 0d15c6cea6 fix(remove-from-view): Fix logic for delete/remove-from-view behavior:
Summary:
- Separate gmail's remove-from-view and delete behaviors and write logic
  for each of those
  - Remove MailboxPerspective::{canArchiveThreads, canTrashThreads,
    removeThreads} and some unecessary code in TaskFactory
  - Instead, add MailboxPerspective::tasksForRemovingFromPerspective (I
    know its a bit of a mouthful)
  - I initially tried to put all of the logic for each execution path
    inside the TaskFactory by checking perspective types, but it made
    more sense to use the polymorphism already in place for the different
    perspective types.
  - There is a default delete/remove-from-view behavior which is
    configurable via simple ruleset objects. The gmail behavior is
    configured in this way.
- Update swipe css classes based on destination of threads
- Fixes #1460:
  - Update logic to display archive/trash buttons and context menu options correctly
    when selected threads can be archived/trashed (not based on
    perspective)
  - Same for swiping
- Add a bunch of specs
- Convert some code to ES6
- TODO write some docs for new functions

Test Plan: Unit tests

Reviewers: drew, evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2682
2016-03-07 18:16:37 -08:00
Juan Tejada 1fe51ef586 fix(date-utils): Add localization to date formats
Summary:
- Setting the locale in moment was not sufficient to actually use the
  correct localized formats.
- Moment provides localized format via the formats : 'L', 'LL', 'll',
  etc. See: http://momentjs.com/docs/#/displaying/format/
- Updates to set our date formats based on localized formats:
  - Unfortunately, localized formats always contain the year, so I
    manually removed the year from our short format.
- Actually fixes: #1515
- Fixes bug where setting nextWeek or thisWeekend returned incorrect
  date if the current day was saturday or sunday
- Add specs

Test Plan: Unit tests

Reviewers: evan, drew, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2688
2016-03-07 16:44:54 -08:00
Juan Tejada 76ce3a62c2 fix(lint) 2016-03-04 10:28:48 -08:00
Ben Gotow fa002b82a5 fix(downloads): Replace stripped extensions, remember folder 2016-03-03 18:00:43 -08:00
Evan Morikawa 4cae9a97a3 feat(quote): add new quoted text detector for quote strings 2016-03-03 17:30:36 -08:00
Evan Morikawa b1b154d526 fix(quoted-text): add test case for intentional quote text failure 2016-03-03 17:30:36 -08:00
Juan Tejada f46502ad3e test(plugins): Add snooze and send later specs
Summary:
- Also refactors the code a bit for testability and maintainability
- Fixes #1515

Test Plan: - Unit tests

Reviewers: evan, drew, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2651
2016-03-03 12:38:42 -08:00
Ben Gotow 68ab8e22c9 fix(drafts): Lock drafts when they're deleted so they can't be revived by deltas
Summary:
When we delete drafts, they can sometimes come back because we receive deltas about them,
find that they're not in the cache, and re-save them.

This diff fixes that by permanently incrementing the optimistic change count, which was also do
to prevent deltas from changing threads while we're in the middle of a request that will change
them further. (This may not actually be necessary anymore, because we'd ignore the delta anyway
due to it's out-of-date version?)

Test Plan: Run a couple new tests

Reviewers: drew, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2665
2016-03-03 12:09:16 -08:00
Ben Gotow a53e72f542 fix(hidden-messages): Address diff feedback from @jstejada 2016-03-02 10:28:32 -08:00
Ben Gotow f5ee557e2e feat(hidden-messages): Filter trash/spam messages. Fixes #1135
Summary:
By default, the messages in a thread are now filtered to exclude
ones moved to trash or spam. You can choose to view those messages by clicking
the new bar in the message list.

When you view your spam or trash, we only show the messages on those threads
that have been marked as spam/trash.

Test Plan: Run a couple new tests

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2662
2016-03-02 10:05:17 -08:00
Ben Gotow 338ef0d56e rename(specs): A few more task renames 2016-03-01 17:34:36 -08:00
Ben Gotow 0caa46bdab test(send): Improved coverage of metadata logic, file uploads
Summary: Just new specs. Tested by manually breaking lots of things in SendDraft

Test Plan: Run new tests

Reviewers: juan, drew, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2649
2016-03-01 17:24:37 -08:00
Evan Morikawa 66d1fe67e8 fix(account): re-add token if a new one comes in
Summary: fix(account): allow users to reconnect accounts if auth has failed

Test Plan: manual

Reviewers: bengotow, juan

Differential Revision: https://phab.nylas.com/D2663
2016-03-01 16:02:20 -08:00
Ben Gotow 94badcda15 es6(*): convert 20+ source files used in example packages to ES2016
There could be a few lurking bugs. Please test!
2016-02-29 18:47:22 -08:00
Juan Tejada 77138c7aef fix(specs): Update spy on persistModel to reflect actual behavior 2016-02-29 10:37:48 -08:00
Ben Gotow 26b8f22a31 fix(402s): Handling of Message Rejected, error messages with more detail 2016-02-26 11:40:59 -08:00
Ben Gotow fe27fb161f fix(link/open tracking): Remove intermediate metadata states, extra db lookup, dead code 2016-02-25 12:54:18 -08:00
Ben Gotow 99e2d3b2d3 fix(sync-draft): Accept the thread id given to the draft server-side 2016-02-24 17:20:12 -08:00
Evan Morikawa 6144f83834 fix(tracking): fix link tracking and read receipt plugins
Fix broken links in link tracking and read receipts

Fix bug in email frame where it wouldn't adjust the height even when
content changed

MessageItem bodies automatically clear the MessageBodyProcessor cache when
the message contents (including metadata) change.

Remove unused Account stuff from nylas-observables

Plugins appIds properly read if there's an environment set
2016-02-24 12:30:12 -08:00
Ben Gotow 29a0da36a3 fix(auth-failure): Warn of disconnect on 403s, fix logic 2016-02-23 18:35:24 -08:00
Ben Gotow 26252801a6 fix(attachments): fixes + specs for download on-receive option 2016-02-19 18:54:20 -08:00
Ben Gotow f63b7e66e4 feat(swipe-to-*): Gesture support and animation in thread list
Summary:
This diff does two things:
- It adds a new SwipeContainer that makes it easy to implement swipe gestures. This is built into listTabular, so you can create a list and define onSwipeLeft/Right to enable gestures.

- It adds support for basic add/remove animations to the thread list. This works by adding a CSS transition to `top` and also leaving removed rows around for a specified time. (these times need to match.) Pretty much just cloned the core idea from TimeoutTransitionGroup.

Test Plan: No tests yet

Reviewers: evan, juan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2581
2016-02-19 18:22:28 -08:00
Juan Tejada 1ba3a64785 feat(metadata): Switch to storing metadata on models
Summary:
 - Adds a class ModelWithMetadata which models can now extend from
 - Instances of this class can query metadata for a plugin via
   `obj.metadataForPluginId(pluginId)`
 - To observe changes on metadata it is sufficient to observe database changes on
   the model. e.g.:
   `DatabaseStore.findAll(Thread,
   [Thread.attributes.pluginMetadata.contains(pluginId)])`
 - To set metadata a new action has been created: Actions.setMetadata
 - Adds a helper observable in nylas-observables to query for models with
   metadata
 - Merges CreateModelTask and UpdateModelTask into SyncbackModelTask
 - Update SendDraftTask ans SynbackDraftTask to handle metadata changes

Test Plan: - Unit tests

Reviewers: drew, evan, bengotow

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2575
2016-02-17 15:00:33 -08:00
Ben Gotow aa8acd357d fix(contacts): Stop auto-capitalizing phrases and emails. Fixes #1308 2016-02-11 16:30:28 -08:00
Juan Tejada 68b6d7df60 fix(focused-persepective): Init saved perspective correctly
- When accounts changed and the saved perspective could reference
  accounts that no longer exist and cause all sorts of errors. This is
  fixed.
- Add specs
- Fixes some sentry errors
2016-02-09 20:10:33 -08:00
Ben Gotow 8a8170eb0e 🎨: Smaller buttons, smaller toolbar, smaller text
This should not be considered final, but we do plan to shrink the size of the entire UI slightly to match platform conventions.
2016-02-09 19:45:24 -08:00
Ben Gotow fbb7a4b40c bump(*): Electron 0.36.7, version to 0.4.6 2016-02-08 18:35:23 -08:00
Ben Gotow 52681baade fix(delete-category): Resolve regression in error message (#1244) 2016-02-08 17:42:48 -08:00
Ben Gotow 53266ea408 perf(accounts): Use cached contact objects in accountForEmail
This method is called for every contact on a thread in the thread list, so I figured we should see if one version was faster. I ran this test code:

```
d = Date.now(); for(var ii = 0; ii < 10000; ii ++){ $n.AccountStore.accountForEmail("ben.gotow@gmail.com") }; console.log(Date.now() - d);
```

The other approach which calls meUsingAlias takes `3784ms`, and this version which uses the alias contacts cached in aliases() only takes `264ms`. Confirmed that the tests still pass.
2016-02-07 11:23:19 -08:00
Juan Tejada 2655054e34 🎨(contact): Reuse AccountStore.accountForEmail inside isMe 2016-02-07 01:34:30 -08:00
Juan Tejada 4641fc4938 fix(account-store): Correctly check alias email inside accountForAlias
- Add spec
2016-02-07 00:39:11 -08:00
Ben Gotow 12f4142d84 fix(system-start): Do not continue when checkAvailability returns false 2016-02-06 11:35:01 -08:00
Ben Gotow 1337b21a0d fix(db): Allow string attributes to be null. Never coerce to ""
- Fixes a bug where reply_to_message_id = "" when we receive drafts from the sever.
- In general behavior should be consistent with API. Since they allow null we should too.
2016-02-05 13:49:18 -08:00
Ben Gotow 56c27ff004 fix(labels): Re-order so adding/removing same label does nothing 2016-02-05 12:00:58 -08:00
Ben Gotow 80b70b6e54 perf(threads): Cache aliases to avoid GC thrashing in isMeAccount 2016-02-04 20:13:37 -08:00
Ben Gotow 8b3f7f0578 feat(outbox): Sending status now appears beside drafts
Summary:
This diff adds an "OutboxStore" which reflects the TaskQueue and
adds a progress bar / cancel button to drafts which are currently sending.

- Sending state is different from things like Send later because drafts
  which are sending shouldn't be editable. You should have to stop them
  from sending before editing. I think we can implement "Send Later"
  indicators, etc. with a simple InjectedComponentSet on the draft list
  rows, but the OutboxStore is woven into the DraftList query subscription
  so every draft has a `uploadTaskId`.

- The TaskQueue now saves periodically (every one second) when there are
  "Processing" tasks. This is not really necessary, but makes it super
  easy for tasks to expose "progress", because they're essentially
  serialized and propagated to all windows every one second with the
  current progress value. Kind of questionable, but super convenient.

- I also cleaned up ListTabular and MultiselectList a bit because they
  applied the className prop to an inner element and not the top one.

- If a DestroyDraft task is created for a draft without a server id, it
  ends with Task.Status.Continue and not Failed.

- The SendDraftTask doesn't delete uploads until the send actually goes
  through, in case the app crashes and it forgets the file IDs it created.

Test Plan: Tests coming soon

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2524
2016-02-04 14:14:24 -08:00
Evan Morikawa d4db0737cf feat(error): improve error reporting. Now NylasEnv.reportError
Summary:
The goal is to let us see what plugins are throwing errors on Sentry.

We are using a Sentry `tag` to identify and group plugins and their
errors.

Along the way, I cleaned up the error catching and reporting system. There
was a lot of duplicate error logic (that wasn't always right) and some
legacy Atom error handling.

Now, if you catch an error that we should report (like when handling
extensions), call `NylasEnv.reportError`. This used to be called
`emitError` but I changed it to `reportError` to be consistent with the
ErrorReporter and be a bit more indicative of what it does.

In the production version, the `ErrorLogger` will forward the request to
the `nylas-private-error-reporter` which will report to Sentry.

The `reportError` function also now inspects the stack to determine which
plugin(s) it came from. These are passed along to Sentry.

I also cleaned up the `console.log` and `console.error` code. We were
logging errors multiple times making the console confusing to read. Worse
is that we were logging the `error` object, which would print not the
stack of the actual error, but rather the stack of where the console.error
was logged from. Printing `error.stack` instead shows much more accurate
stack traces.

See changes in the Edgehill repo here: 8c4a86eb7e

Test Plan: Manual

Reviewers: juan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2509
2016-02-03 18:06:52 -05:00
Evan Morikawa 5561462568 feat(metadata): add cloudState that sync with Metadata service
Summary:
Now all plugins get passed a `cloudState` object to their `activate`
method.

The `cloudState` object is an instance of `CloudState` and acts like a
key-value store backed by the yet-to-be-implemented Metadata service.

It has a `get`, `getAll`, and `observe` method. The `observe` method
returns a new `Rx.Observable` for the given key.

It has a `set`, and `unset` method that doesn't actually mutate state, but
rather dispatches new `Task`s to Create, Update, and Delete `Metadata`
objects.

The whole object is backed by `Metadata` objects. Since these are standard
Database Objects that will appear on the delta sync streaming API, any
updates from the server will automatically propagate down to listening
views via the `Rx.Observable`s.

Additionally, there is a new `N1-Send-Later` stub plugin that demonstrates
how to use the `cloudState`.

There are few other minor refactors included in this diff:

**Generic CUD Tasks**: There is now a generic `CreateModelTask`,
`UpdateModelTask`, and `DestroyModelTask`. These can either be used as-is
or trivially overridden to easily update simple objects. Hopefully all of
the boilerplate rollback, error handling, and undo logic won't have to be
re-duplicated on every task. There are also tests for these tasks. We use
them to perform mutating actions on `Metadata` objects.

**New `boundProps` for `InjectedComponents`**: When making the
`N1-Send_later` plugin, I realized that the injected component needed to
get the `cloudState` somehow. Traditionally components would require
Stores and load data that way, but these are setup at `require`-time. Now
that `cloudState` only is available on `activate` we needed a way to get
the data to the components. There's now the concept of `boundProps` which
will be props added to the Component when it gets injected. This required
changing the return signature of `findComponentMatching`, which got
renamed to `findComponentDataMatching`.

**Failing on Promise Rejects**: Turns out that if a Promise rejected
due to an error or `Promise.reject` we were ignoring it and letting tests
pass. Now, tests will Fail if any unhandled promise rejects. This
uncovered a variety of errors throughout the test suite that had to be
fixed. The most significant one was during the `theme-manager` tests when
all packages (and their stores with async DB requests) was loaded. Long
after the `theme-manager` specs finished, those DB requests were
(somtimes) silently failing.

**Globally stub `DatabaseStore._query`**: All tests shouldn't actually
make queries on the database. Furthremore, the `inTransaction` block
doesn't resolve at all unless `_query` is stubbed. Instead of manually
remembering to do this in every test that touches the DB, it's now mocked
in `spec_helper`. This broke a handful of tests that needed to be manually
fixed.

**ESLint Fixes**: Some minor fixes to the linter config to prevent
yelling about minor ES6 things and ensuring we have the correct parser.

Test Plan: new tests

Reviewers: drew, bengotow, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2419
2016-02-02 15:28:06 -05:00