Commit graph

181 commits

Author SHA1 Message Date
Ben Gotow 3d3f7fa315 fix(mailto): test case / parsing for url encoded To field 2016-02-01 11:22:23 -08:00
Ben Gotow 10a8defc40 fix(uploads): Consolidate logic, use Promisify, path.join 2016-01-29 14:45:53 -08:00
Juan Tejada ced31d7f5d fix(electron): Update api usage to require('electron') 2016-01-29 14:24:33 -08:00
Ben Gotow 54d30a31b3 fix(specs): Re-enable draft-store specs 2016-01-28 15:48:08 -08:00
Ben Gotow 09a2096690 fix(linter): Switching between Coffee + ES6 is hard... 2016-01-28 14:59:17 -08:00
Ben Gotow 3869b9c214 fix(contact-search): Keep only ranked contacts, query for others. Massive perf boost. 2016-01-28 14:56:15 -08:00
Ben Gotow 46b339d334 fix(message-list): Spec fixes, all stubs need accountId 2016-01-28 11:14:04 -08:00
Juan Tejada b9cfb18244 Fix in upload store when deleting draft 2016-01-28 01:29:33 -08:00
Juan Tejada 21f0afd825 Fix specs 2016-01-28 00:48:45 -08:00
Juan Tejada 9a86ce06ed 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 7b6267e0b2 Rewrite tests for FileUploadStore 2016-01-27 12:33:27 -08:00
Ben Gotow efdb5c5b6c More spec fixes 2016-01-27 10:31:54 -08:00
Ben Gotow f4ca355bf4 Spec fixes 2016-01-26 19:12:51 -08:00
Ben Gotow a05f6c449c Fixes to the SendDraftTask 2016-01-26 16:41:49 -08:00
Ben Gotow 2783045c3e Begin cleanup of Send Task 2016-01-26 15:44:44 -08:00
Ben Gotow e2234bf58e 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 22121f9f18 Fix drafts 2016-01-25 16:37:34 -08:00
Evan Morikawa ecbadaf01e 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
Juan Tejada 1f68a574d3 Fix NylasAPI specs and ContactStore specs 2016-01-25 12:12:16 -08:00
Ben Gotow 2bb9ce3591 More database-related spec fixes 2016-01-25 11:35:23 -08:00
Ben Gotow a2c901559e DatabaseTransaction / QueryBuilder spec fixes 2016-01-25 11:11:57 -08:00
Ben Gotow 9fc11512ad CategoryPicker / PerspectiveStore spec fixes 2016-01-25 11:07:40 -08:00
Juan Tejada b538ec050c 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 96f429ff39 Unified inbox mailbox perspectives working (sidebar disabled atm) 2016-01-18 00:47:04 -08:00
Evan Morikawa 6695de4187 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 3a8a38b8bc Merge branch 'master' into unified-inbox
# Conflicts:
#	spec/stores/file-download-store-spec.coffee
2016-01-13 17:20:34 -08:00
Ben Gotow ba9af70b16 fix(accounts): Spec fixes for a03e8f70 2016-01-12 15:16:59 -08:00
Ben Gotow 8f45633fea fix(downloads): Escape all illegial path chars, don't make regex from path.sep 2016-01-12 13:52:01 -08:00
Ben Gotow 13870fecd5 Merge branch 'master' into unified-inbox
# Conflicts:
#	internal_packages/events/lib/event-header.cjsx
#	spec/stores/file-download-store-spec.coffee
#	spec/tasks/event-rsvp-spec.coffee
#	src/flux/tasks/event-rsvp.coffee
2016-01-12 08:20:55 -08:00
Juan Tejada 813598d536 Fix more specs:
- SearchBar
- EventRSVPTask
- ContactStore
2016-01-11 16:14:21 -08:00
Ben Gotow 212adcdf84 Search bar fixes 2016-01-11 15:58:10 -08:00
Ben Gotow 7b6f122119 AccountStore no longer tracks index, Actions.selectAccount gone 2016-01-11 14:11:48 -08:00
Juan Tejada 6963d11491 Wrap FileDownloadStore in describe block 2016-01-11 13:44:54 -08:00
Ben Gotow 651ea8c1c5 More spec fixes 2016-01-11 13:40:42 -08:00
Ben Gotow a352e40af7 fixes for draft store specs, contact.isMe now returns true if it matches any account 2016-01-11 13:23:35 -08:00
Ben Gotow 3160520017 fix(downloads): Replace path.sep when saving files - Sentry 8749 2016-01-11 11:49:05 -08:00
Ben Gotow 14d6cec669 Rename MailViewFilter => MailboxPerspective 2016-01-08 14:58:31 -08:00
Juan Tejada 6315bc9d80 fix(extension-adapter): Update adapter to support all versions of extension api we've used
Summary:
- Rewrites composer extension adpater to support all versions of the
  ComposerExtension API we've ever declared. This will allow old plugins (or
  plugins that haven't been reinstalled after update) to keep functioning
  without breaking N1
- Adds specs

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2399
2015-12-30 15:11:37 -05:00
Ben Gotow e349062835 fix(regex): Chop leading '/" off emails if they are wrapped in quotes 2015-12-28 18:39:06 -08:00
Ben Gotow fb862e9b74 fix(mailto): Parse query string manually to account for unencoded body (Fixes #815) 2015-12-28 13:58:24 -08:00
Evan Morikawa c2f47ce951 fix(draft): New Send Draft logic
Summary:
This is a WIP for the new send draft logic.

I'll add tests then update the diff

Test Plan: todo

Reviewers: bengotow, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2341
2015-12-21 11:50:52 -08:00
Ben Gotow ea76b7c442 feat(transactions): Explicit (and faster) database transactions
Summary:
Until now, we've been hiding transactions beneath the surface. When you call persistModel, you're implicitly creating a transaction.
You could explicitly create them with `atomically`..., but there were several critical problems that are fixed in this diff:

- Calling persistModel / unpersistModel within a transaction could cause the DatabaseStore to trigger. This could result in other parts of the app making queries /during/
  the transaction, potentially before the COMMIT occurred and saved the changes. The new, explicit inTransaction syntax holds all changes until after COMMIT and then triggers.

- Calling atomically and then calling persistModel inside that resulted in us having to check whether a transaction was present and was gross.

- Many parts of the code ran extensive logic inside a promise chained within `atomically`:

  BAD:

```
  DatabaseStore.atomically =>
   DatabaseStore.persistModel(draft) =>
     GoMakeANetworkRequestThatReturnsAPromise
```

OVERWHELMINGLY BETTER:

```
  DatabaseStore.inTransaction (t) =>
     t.persistModel(draft)
  .then =>
    GoMakeANetworkRequestThatReturnsAPromise
```

Having explicit transactions also puts us on equal footing with Sequelize and other ORMs. Note that you /have/ to call DatabaseStore.inTransaction (t) =>. There is no other way to access the methods that let you alter the database. :-)

Other changes:
- This diff removes Message.labels and the Message-Labels table. We weren't using Message-level labels anywhere, and the table could grow very large.
- This diff changes the page size during initial sync from 250 => 200 in an effort to make transactions a bit faster.

Test Plan: Run tests!

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D2353
2015-12-17 11:46:05 -08:00
Juan Tejada 823dab988b refactor(extensions): Move extensions outside of flux/ folder
Not really related to flux, makes more sense to be inside src/
2015-12-13 23:33:42 -08:00
Juan Tejada fc69d2dbf6 fix(warnings): Remove deprecate warnings from specs 2015-12-13 23:32:24 -08:00
Juan Tejada 415d612458 feat(account-prefs): Adds new page for Account in preferences
Summary:
Adds the new Account preferences page. This consists of two major React components,
PreferencesAccountList and PreferencesAccountDetails, both of which use EditableList.

I added a bunch of fixes and updated the API for EditableList, plus a bit of
refactoring for PreferencesAccount component, and a bunch of CSS so its a big diff.

The detailed changelog:

Updates to EditableList:
  - Fix bug updating selection state when arrows pressed to move selection
  - Add new props:
    - allowEmptySelection to allow the list to have no selection
    - createInputProps to pass aditional props to the createInput
  - Add scroll region for list items
  - Update styles and refactor render methods

Other Updates:
- Updates Account model to hold aliases and a label
  - Adds getter for label to default to email
- Update accountswitcher to display label, update styles and spec

- Refactor PreferencesAccounts component:
  - Splits it into smaller components,
  - Removes unused code
- Splits preferences styelsheets into smaller separate stylesheet for
  account page. Adds some updates and fixes (scroll-region padding)
- Update AccountStore to be able to perform updates on an account.
- Adds new Action to update account, and an action to remove account to
  be consistent with Action usage
- Adds components for Account list and Aliases list using EditableList

Test Plan: - All specs pass, but need to write new tests!

Reviewers: bengotow, evan

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2332
2015-12-10 15:27:29 -08:00
Ben Gotow 62fab52f7b feat(observables): Implementation of observables to replace some stores
Summary:
Add concept of "final" to Query, clean up internals

Tiny bug fixes

RxJs Observables!

WIP

Test Plan: Run tests

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2319
2015-12-07 16:52:46 -08:00
Ben Gotow b00e5439e5 feat(paste): Paste accepts more HTML, paste and match style now available
Summary:
Related to #320, #494, #515, #553

Ignore newlines and returns in HTML, they can be inside tags

Allow all attributes so that paste from excel looks nice

Never let someone paste a `contenteditable` attribute

Update specs

Test Plan: Run new specs

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2309
2015-12-07 15:34:03 -08:00
Ben Gotow f8169273b8 fix(downloads): Improve inline attachment handling
- Show downloading state for inline attachments
- Ensure that the UI updates /after/ the download has completed
- Don't delete finished downloads (previously we were forgetting that a file was downloaded and checking again and again)

Fixes #462
2015-12-07 15:00:25 -08:00
Ben Gotow d19533ff7f fix(counts): compute deltas for unpersist events, more specs
This fix should resolve #489
2015-12-04 16:29:26 -08:00
Juan Tejada e45a7526db feat(messages): Add button to expand/collapse all messages in thread
Summary:
- Works like Gmail does
- Adds specs

Test Plan: - Unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2301
2015-12-03 11:57:48 -08:00
Ben Gotow 99c20f3b56 fix(badge): Badge respects option in prefs
Fixes #516
2015-11-30 19:17:35 -08:00
Juan Tejada cfdc401c54 update(extensions): Rename DraftStoreExtension and MessageStoreExtension
Summary:
- Rename DraftStoreExtension to ComposerExtension
- Rename MessageStoreExtension to MessageViewExtension
- Rename ContenteditablePlugin to ContenteditableExtension
  - Update Contenteditable to use new naming convention
  - Adds support for extension handlers as props
- Add ExtensionRegistry to register extensions:
  - ContenteditableExtensions will not be registered through the
    ExtensionRegistry. They are meant for internal use, or if anyone wants
    to use our Contenteditable component directly in their plugins.
  - Adds specs
- Refactors internal_packages and src to use new names and new ExtensionRegistry api
- Adds deprecation util function and deprecation notices for old api methods:
  - DraftStore.{registerExtension, unregisterExtension}
  - MessageStore.{registerExtension, unregisterExtension}
  - DraftStoreExtension.{onMouseUp, onTabDown}
  - MessageStoreExtension
- Adds and updates docs

Test Plan: - Unit tests

Reviewers: bengotow, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2293
2015-11-30 16:08:05 -08:00
Ben Gotow 1739a19d21 fix(counts): Ensure serial execution of persistModels, unpersistModels
Summary:
reduce scope of changes

more changes

Test Plan: Run 1 new test

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2290
2015-11-25 12:17:00 -08:00
Ben Gotow a82ebba618 fix(attachments): Only preview images up to 5MB, not 10MB 2015-11-24 16:27:07 -08:00
Ben Gotow 9dda306d1f fix(counts): Expand tests, fix edge cases in count tracking 2015-11-24 15:14:00 -08:00
Ben Gotow f5fff1322b perf(db): Flip order of columns in join table indexes for much faster querying 2015-11-24 15:14:00 -08:00
Ben Gotow 528c8850ce bump(electron): 0.34.3 => 0.35.1
Electron 0.35.1 includes the tray fixes we contributed last week but also includes API restructuring and improvements. Most importantly, modules from electron are now imported via `require('electron')`
2015-11-23 22:09:17 -08:00
Ben Gotow e1882ab61a feat(counts): Unread counts for all folders and labels across all accounts
Summary:
This diff replaces the UnreadCountStore with a better approach that is able to track unread counts for all folders/labels without continuous (and cripplingly slow) SELECT COUNT(*) queries.

When models are written to the database, we currently don't send out notifications with the "previous" state of those objects in the database. This makes it hard to determine how to update counters. (In the future, we may need to do this for live queries). Unfortunately, getting the "previous" state is going to be very hard, because multiple windows write to the database and the "previous" state we have might be outdated. We'd almost have to run a "SELECT" right before every "REPLACE INTO".

I created an API that allows you to register observers around persistModel and unpersistModel. With this API, you can run queries before and after the database changes are made and pluck just the "before" state you're interested in.

The `ThreadCountsStore` uses this API to determine the impact of persisting a set of threads on the unread counts of different labels. Before the threads are saved, it says "how much do these thread IDs contribute to unread counts currently?". After the write is complete it looks at the models and computes the difference between the old count impact and the new count impact, and updates the counters.

I decided not to attach the unread count to the Label objects themselves because 1) they update frequently and 2) most things observing the DatabaseStore for categories do not care about counts, so they would be updating unnecessarily.

The AccountSidebar now listens to the ThreadCountsStore as well as the CategoryStore, and there's a new preference in the General tab for turning off the counts.

Test Plan: Tests are a work in progress, want to get feedback first!

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2232
2015-11-23 17:12:22 -08:00
Evan Morikawa 0c93cb856f fix(draft): fix showing of incorrect body when pending send
Summary: Fixes T3712

Test Plan: new tests

Reviewers: juan, bengotow

Reviewed By: bengotow

Maniphest Tasks: T3712

Differential Revision: https://phab.nylas.com/D2273
2015-11-18 12:32:07 -08:00
Evan Morikawa 488dff0f90 refactor(env): new NylasEnv global
Converted all references of global atom to NylasEnv

Temporary rename atom.io

find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.io/temporaryAtomIoReplacement/g'

atom.config to NylasEnv.config

find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.config/NylasEnv.config/g'

atom.packages -> NylasEnv.packages

atom.commands -> NylasEnv.commands atom.getLoadSettings

find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.commands/NylasEnv.commands/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.getLoadSettings/NylasEnv.getLoadSettings/g'

More common atom methods

find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.styles/NylasEnv.styles/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.emitError/NylasEnv.emitError/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.inSpecMode/NylasEnv.inSpecMode/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.inDevMode/NylasEnv.inDevMode/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.getWindowType/NylasEnv.getWindowType/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.displayWindow/NylasEnv.displayWindow/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.quit/NylasEnv.quit/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.close/NylasEnv.close/g'

More atom method changes

find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.keymaps/NylasEnv.keymaps/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.hide/NylasEnv.hide/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.getCurrentWindow/NylasEnv.getCurrentWindow/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.menu/NylasEnv.menu/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.getConfigDirPath/NylasEnv.getConfigDirPath/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.isMainWindow/NylasEnv.isMainWindow/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.finishUnload/NylasEnv.finishUnload/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.isWorkWindow/NylasEnv.isWorkWindow/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.showSaveDialog/NylasEnv.showSaveDialog/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.append/NylasEnv.append/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.confirm/NylasEnv.confirm/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.clipboard/NylasEnv.clipboard/g'
find -E . -regex ".*\.(coffee|cjsx|js|md|cmd|es6)" -print0 | xargs -0 sed
-i "" 's/atom.getVersion/NylasEnv.getVersion/g'

More atom renaming

Rename atom methods

More atom methods

Fix grunt config variable

Change atom.cmd to N1.cmd

Rename atom.coffee and atom.js to nylas-env.coffee nylas-env.js

Fix atom global reference in specs manually

Fix atom requires

Change engine from atom to nylas

got rid of global/nylas-env

rename to nylas-win-bootup

Fix onWindowPropsChanged to onWindowPropsReceived

fix nylas-workspace

atom-text-editor to nylas-theme-wrap

atom-text-editor -> nylas-theme-wrap

Replacing atom keyword

AtomWindow -> NylasWindow

Replace Atom -> N1

Rename atom items

nylas.asar -> atom.asar

Remove more atom references

Remove 6to5 references

Remove license exception for atom
2015-11-17 16:41:20 -08:00
Ben Gotow ed585b0d3e fix(mailto): Handle mailto links with newline characters #397
Regex was clipping off the body after the first newline. Fixes #397
2015-11-13 10:58:42 -08:00
Ben Gotow 118761d79e perf(db): Lazily deserialize models on the other side of the action bridge
Summary:
We send database `trigger()` events through the ActionBrige to all windows of the app. This means that during initial sync, we're serializing, IPCing and unserializing thousands of models a minute x "N" windows.

This diff converts the payload of the trigger method into an actual class that implements a custom toJSON. It converts the impacted `objects` into a string, and doesn't deserialize them until it's asked.

Bottom line: this means that in many scenarios, we can avoid creating Contact models, etc. in composer windows only to broadcast them and then gc them.

Test Plan: No new tests yet, but this should definitel be tested. #willfix.

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2236
2015-11-06 11:15:20 -08:00
Ben Gotow 25ffea50f9 perf(message-store): Debounce reload of the message column—#249 2015-10-29 20:20:49 -07:00
Evan Morikawa 1febd56ed5 fix(drafts): only syncback every 30 seconds instead of 5 seconds
This will help prevent API errors from causing multiple drafts to appear
2015-10-28 19:51:46 -04:00
Evan Morikawa 849736fcd5 fix(unread): can mark message as unread in split mode
Summary: Fixes T4835

Test Plan: new tests

Reviewers: bengotow

Reviewed By: bengotow

Maniphest Tasks: T4835

Differential Revision: https://phab.nylas.com/D2205
2015-10-28 17:50:07 -04:00
Evan Morikawa ef8e7aaf51 fix(databse): fix memory leak on DatabaseStore.atomically
Summary:
The Promise chain we were creating was never cleared and created a memory
leak. We instead use a `PromiseQueue` to cleanup finished promises.

Also added several more tests and verified that the memory leak is gone
with the Chrome profiler

Test Plan: new tests

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2184
2015-10-22 14:19:39 -07:00
Evan Morikawa cfb4142471 fix(event): remove EventStore
Summary:
The EventStore was really doing nothing, except caching hundreds of MB of
event data unnecessarily in each and every window :(

Test Plan: manual

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2187
2015-10-22 14:14:58 -07:00
Evan Morikawa c5b9f6a634 fix(spec): fix contact store spec
Since it's not Promise-based anymore. It was just the spec that relied on
this.
2015-10-22 14:13:51 -07:00
Ben Gotow 6f587d6d98 rm(metadata): MetadataStore is not in use, should be rebuilt
Resolves a request that happens whenver the user starts the app, reported in #108
2015-10-21 14:30:33 -07:00
Ben Gotow c5cdbc1993 fix(uploads): Display error when uploading >25MB files
Fixes GitHub issue #102
2015-10-21 12:29:07 -07:00
Evan Morikawa 092c28d2c0 fix(tasks): don't continue if dependent task fails
Summary:
Fixes T4291

If I made a final edit to a pre-existing draft and sent, we'd queue a
`SyncbackDraftTask` before a `SendDraftTask`. This is important because
since we have a valid draft `server_id`, the `SendDraftTask` will send by
server_id, not by POSTing the whole body.

If the `SyncbackDraftTask` fails, then we had a very serious issue whereby
the `SendDraftTask` would keep on sending. Unfortunately the server never
got the latest changes and sent the wrong version of the draft. This
incorrect version would show up later when the `/send` endpoint returned
the message that got actually sent.

The solution was to make any queued `SendDraftTask` fail if a dependent
`SyncbackDraftTask` failed.

This meant we needed to make the requirements for `shouldWaitForTask`
stricter, and block if tasks failed.

Unfortunatley there was no infrastructure in place to do this.

The first change was to change `shouldWaitForTask` to `isDependentTask`.
If we're going to fail when a dependent task fails, I wanted the method
name to reflect this.

Now, if a dependent task fails, we recursively check the dependency tree
(and check for cycles) and `dequeue` anything that needed that to succeed.

I chose `dequeue` as the default action because it seemed as though all
current uses of `shouldWaitForTask` really should bail if their
dependencies fail. It's possible you don't want your task dequeued in this
dependency case. You can return the special `Task.DO_NOT_DEQUEUE_ME`
constant from the `onDependentTaskError` method.

When a task gets dequeued because of the reason above, the
`onDependentTaskError` callback gets fired. This gives tasks like the
`SendDraftTask` a chance to notify the user that it bailed. Not all tasks
need to notify.

The next big issue was a better way to determine if a task truely errored
to the point that we need to dequeue dependencies. In the Developer Status
area we were showing tasks that had errored as "Green" because we caught
the error and resolved with `Task.Status.Finished`. This used to be fine
since nothing life-or-death cared if a task errored or not. Now that it
might cause abortions down the line, we needed a more robust method then
this.

For one I changed `Task.Status.Finished` to a variety of finish types
including `Task.Status.Success`. The way you "error" out is to `throw` or
`Promise.reject` an `Error` object from the `performRemote` method. This
allows us to propagate API errors up, and acts as a safety net that can
catch any malformed code or unexpected responses.

The developer bar now shows a much richer set of statuses instead of a
binary one, which was REALLY helpful in debugging this. We also record
when a Task got dequeued because of the conditions introduced here.

Once all this was working we still had an issue of sending old drafts.

If after a `SyncbackDraftTask` failed, now we'd block the send and notify
the users as such. However, if we tried to send again, there was a
separate issue whereby we wouldn't queue another `SyncbackDraftTask` to
update the server with the latest information. Since our changes were
persisted to the DB, we thought we had no changes, and therefore didn't
need to queue a `SyncbackDraftTask`.

The fix to this is to always force the creation of a `SyncbackDraftTask`
before send regardless of the state of the `DraftStoreProxy`.

Test Plan: new tests. Lots of manual testing

Reviewers: bengotow

Reviewed By: bengotow

Subscribers: mg

Maniphest Tasks: T4291

Differential Revision: https://phab.nylas.com/D2156
2015-10-21 10:33:43 -07:00
Evan Morikawa 2859baa134 fix(contact): fix bug where malformed contacts threw an error
Summary:
Also added tests to catch the case
Fixes T4290

Test Plan: new tests

Reviewers: bengotow

Reviewed By: bengotow

Maniphest Tasks: T4290

Differential Revision: https://phab.nylas.com/D2153
2015-10-12 14:03:39 -04:00
Evan Morikawa abc4a6116e fix(specs): Fix intermittent async error and max event listener leak
An absolute ContactStore spec was causing the listener leak by
re-initializing the store and not cleaning it up.

Intermittent theme manager failing spec might be caused due to timing of
the theme activation
2015-10-09 15:42:37 -07:00
Ben Gotow 7ad57680ca fix(contacts): Emails only valid if the entire string is the email. (Sentry 2991) 2015-10-09 14:30:08 -07:00
Ben Gotow 9107bc325e fix(specs): ContactStore spec fixes for new contact ranking support 2015-10-09 13:42:24 -07:00
Evan Morikawa dfab406484 Fix contact ranking and add tests
Summary:
Contact ranking is now tested.

There was a bug whereby the RankingsJSONCache would only update in the
workerwindow. This regressed when Contact ranking moved exclusively into
the main window and separate composer windws requested rankings via ipc

Test Plan: New tests

Reviewers: drew, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2134
2015-10-09 09:31:52 -07:00
Ben Gotow ebdf06b183 fix(attachments): When downloads fail, don't resolve to chained actions
Summary: Fixes Sentry 3319 and 3303

Test Plan: Run three new tests

Reviewers: dillon, evan

Reviewed By: dillon, evan

Differential Revision: https://phab.nylas.com/D2118
2015-10-05 17:57:24 -07:00
Ben Gotow a8228238d3 fix(specs): Clean up spec failures due to hot fixes prior to launch 2015-10-05 16:45:30 -07:00
Evan Morikawa 2a7496642c fix(specs): specs run clean 2015-10-02 18:44:12 -07:00
Evan Morikawa 4651fe5350 fix(sounds): make sounds listen to config options
Summary: Fixes T3887

Test Plan: new specs

Reviewers: bengotow

Reviewed By: bengotow

Projects: #edgehill

Maniphest Tasks: T3887

Differential Revision: https://phab.nylas.com/D2104
2015-10-02 17:04:15 -07:00
Evan Morikawa 57fef805cd refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00