Commit graph

214 commits

Author SHA1 Message Date
Ben Gotow 8a40af6830 fix(labels): Re-order so adding/removing same label does nothing 2016-02-05 12:00:58 -08:00
Ben Gotow 1ca2e930ef perf(threads): Cache aliases to avoid GC thrashing in isMeAccount 2016-02-04 20:13:37 -08:00
Ben Gotow 91240f8979 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 918090a4e1 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 8b895068e2 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
Ben Gotow d9c4739f78 fix(contact): Converge on displayName(), don't show account label in ThreadList. Fixes #1157 2016-02-01 19:12:06 -08:00
Juan Tejada 617e2aed09 fix(remove-from-view): Update remove from view (shortcut) behavior
Summary:
- Now behaves exactly like in Gmail:
  - If viewing inbox, it will archive or trash, depending on setting
  - If viewing starred, will unstar
  - If viewing trash, will move to inbox
  - If viewing label, will remove label (no folder support)
  - No op otherwise
- Updates TaskFactory helpers and adds some helper methods
- Updates specs

Test Plan: - Manual

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2492
2016-02-01 17:40:42 -08:00
Juan Tejada 46f331c0b1 fix(alias-list): Editable list wont create empty items
- Update alias coercion to include name by default
2016-02-01 12:45:52 -08:00
Ben Gotow 3453cfecb5 fix(mailto): test case / parsing for url encoded To field 2016-02-01 11:22:23 -08:00
Ben Gotow 2027901deb fix(uploads): Consolidate logic, use Promisify, path.join 2016-01-29 14:45:53 -08:00
Juan Tejada a3b686e546 fix(electron): Update api usage to require('electron') 2016-01-29 14:24:33 -08:00
Ben Gotow f1a9080518 feat(me): Display "Me (Account Label)" in unified inbox 2016-01-29 09:29:25 -08:00
Ben Gotow 21aa4b4291 perf(accounts): Cache accountForId - need ordered map...
In general, we call the functions in AccountStore and CategoryStore / constantly / and inside of critical places like thread list render. Would be nice to create a safe and generic way of caching things and invalidating them when data changes.
2016-01-29 00:42:56 -08:00
Ben Gotow 140162dcd3 fix(db): Pool, flush change records rather than cancel queries 2016-01-28 23:20:19 -08:00
Evan Morikawa 256b240b70 fix(quoted): fix quoted text issue with single blockquotes
Fixes #1084
Also fixes broken tokenizing text field specs
Also protects `MessageBodyExtension`s from errors
2016-01-28 17:25:36 -08:00
Evan Morikawa 15cafbac4d fix(apm): no longer overrides apm
Summary: Fixes #39

Test Plan: new tests

Reviewers: juan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2481
2016-01-28 16:06:27 -08:00
Ben Gotow a4e37c66f4 fix(specs): Re-enable draft-store specs 2016-01-28 15:48:08 -08:00
Ben Gotow 52a7a6625f fix(linter): Switching between Coffee + ES6 is hard... 2016-01-28 14:59:17 -08:00
Ben Gotow d1415585d5 fix(contact-search): Keep only ranked contacts, query for others. Massive perf boost. 2016-01-28 14:56:15 -08:00
Juan Tejada f00f7c56f8 add(specs): Add specs for MailboxPerspective
- Renames canApplyToThreads -> canReceiveThreads and applyToThreads ->
  receiveThreads
- Add initial specs and better documentation for
  MailboxPerspective.canReceiveThreads.
2016-01-28 14:11:50 -08:00
Ben Gotow 63102ba732 fix(message-list): Spec fixes, all stubs need accountId 2016-01-28 11:14:04 -08:00
Juan Tejada 8be8bfcab2 Fix in upload store when deleting draft 2016-01-28 01:29:33 -08:00
Juan Tejada f74ee7b6c2 Fix specs 2016-01-28 00:48:45 -08:00
Juan Tejada 3343000f86 Update file uploads (see details):
- Add uploads field to Message and removes cache from FileUploadsStore
- Updates draft via session from DraftStore
  - This makes everything way cleaner
- This fixes bug when creating draft with uploads and the opening it in
  new window
- Updates specs
2016-01-28 00:33:22 -08:00
Juan Tejada ff3213f003 Rewrite tests for FileUploadStore 2016-01-27 12:33:27 -08:00
Ben Gotow 32ccaad1e7 More spec fixes 2016-01-27 10:31:54 -08:00
Ben Gotow 3b3b19a172 Spec fixes 2016-01-26 19:12:51 -08:00
Ben Gotow 820973cfa5 Fixes to the SendDraftTask 2016-01-26 16:41:49 -08:00
Ben Gotow bbe2f80320 A few other changes 2016-01-26 15:44:44 -08:00
Ben Gotow c8bd09a260 Begin cleanup of Send Task 2016-01-26 15:44:44 -08:00
Ben Gotow 0ef4911b22 Merge branch 'master' into unified-inbox
# Conflicts:
#	internal_packages/feedback/lib/feedback-button.cjsx
#	internal_packages/thread-list/lib/thread-list.cjsx
#	src/flux/stores/draft-store.coffee
2016-01-25 17:28:29 -08:00
Ben Gotow e4553ffb1e Fix drafts 2016-01-25 16:37:34 -08:00
Evan Morikawa 392753233e feat(send): Send and Archive
Summary: Send and Archive plus a new setting.

Test Plan: new tests

Reviewers: bengotow, juan

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2446
2016-01-25 14:14:09 -08:00
Ben Gotow c6bf3eba01 Fix for selection update issue, delete items + scroll up issue 2016-01-25 13:44:05 -08:00
Juan Tejada 84bf7dded6 Fix NylasAPI specs and ContactStore specs 2016-01-25 12:12:16 -08:00
Ben Gotow c9e5b68f16 More database-related spec fixes 2016-01-25 11:35:23 -08:00
Ben Gotow 6a28cd8cda DatabaseTransaction / QueryBuilder spec fixes 2016-01-25 11:11:57 -08:00
Ben Gotow fcb75fbf1a CategoryPicker / PerspectiveStore spec fixes 2016-01-25 11:07:40 -08:00
Juan Tejada 01ad283754 Fix more task specs 2016-01-22 16:55:29 -08:00
Juan Tejada c5dc9544e1 Fix specs for destroy and syncback category tasks 2016-01-22 14:52:19 -08:00
Juan Tejada ad05cc05cc Fix MutliSelectSplitInteractionHandler specs 2016-01-22 13:47:54 -08:00
Ben Gotow d842428880 Rename formatResult, don't assume it's an array 2016-01-22 11:45:36 -08:00
Juan Tejada 6b144b867d Fix MultiSelectListInteractionHandlers specs 2016-01-21 17:07:57 -08:00
Juan Tejada f2acba48ee Add account switcher back to sidebar:
- Account switcher can now switch between all accounts and each account
- Updates FocusedPerspectiveStore and Actions.focusDefaultMailboxPerspectiveForAccounts
  to focus a perspective for accountIds instead of for a single account,
  and updates methods
  - Adds helpers to CategoryStore and MailboxPerspective
  - Updates key commands to allow switch to unified inbox
2016-01-19 23:42:50 -08:00
Ben Gotow 1e5b26a818 Unified inbox mailbox perspectives working (sidebar disabled atm) 2016-01-18 00:47:04 -08:00
Evan Morikawa 74e21bce16 feat(tasks): add Create, Update, Destroy tasks plus spec & lint fixes
Summary:
1. **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.

1. **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.

1. **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.

1. **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: bengotow, juan, drew

Differential Revision: https://phab.nylas.com/D2419

Remove cloudState and N1-Send-Later
2016-01-15 15:16:21 -05:00
Ben Gotow 273679a861 DataView => ListDataSource 2016-01-14 12:26:54 -08:00
Ben Gotow 88b901d8a5 New QueryRange specs, fixes 2016-01-14 12:03:06 -08:00
Ben Gotow 9814d80d5a New MutableQueyResultSet specs, fixes 2016-01-14 11:25:52 -08:00
Ben Gotow cb5f2985ef Merge branch 'master' into unified-inbox
# Conflicts:
#	spec/stores/file-download-store-spec.coffee
2016-01-13 17:20:34 -08:00