Commit graph

66 commits

Author SHA1 Message Date
Ben Gotow 6170b34533 perf(message-store): Debounce reload of the message column—#249 2015-10-29 20:20:49 -07:00
Evan Morikawa cc61aa7811 feat(signatures): add signature support in preferences
Summary:
Adding signature support in preferences

Extracting out DraftStore extensions from the Contenteditable component

Moved Contenteditable to the nylas component kit

Build react remote window selection synchronization.

Test Plan: todo

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2204
2015-10-29 17:20:41 -04:00
Evan Morikawa 78f6829c1b doc(task): make methods public and add documentation 2015-10-29 15:11:01 -04:00
Evan Morikawa d0212c3dd9 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 ede7eda3c4 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 ad5274049d 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 e9acc3d315 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 ada6e5a2f6 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 fddac45687 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 2f28b0ad02 fix(uploads): Display error when uploading >25MB files
Fixes GitHub issue #102
2015-10-21 12:29:07 -07:00
Ben Gotow 4810775924 fix(tasks): SyncbackCategory does not need organizationUnit 2015-10-21 11:07:08 -07:00
Ben Gotow 98a2464e0f fix(specs): Unbreak tests for CategoryPicker 2015-10-21 10:57:42 -07:00
Ben Gotow 4f34c8403f feat(trash): Trash for Gmail, and architectural changes for common tasks
Summary:
This diff centralizes logic for creating common tasks for things like moving to trash, archive, etc. TaskFactory exposes a set of convenience methods and hides the whole "and also remove the current label" business from the user.

This diff also formally separates the concept of "moving to trash" and "archiving" so that "remove" isn't used in an unclear way.

I also refactored where selection is managed. Previously you'd fire some action like archiveSelection and it'd clear the selection, but if you selected some items and used another method to archive a few, they were still selected. The selection is now bound to the ModelView as intended, so if items are removed from the modelView, they are removed from it's attached selection. This means that it shouldn't /technically/ be possible to have selected items which are not in view.

I haven't refactored the tests yet. They are likely broken...

Fix next/prev logic

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2157
2015-10-21 10:38:00 -07:00
Evan Morikawa 531118ac5c 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 78a3218c26 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 b0b0c14d03 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 7ebb27cdfa fix(contacts): Emails only valid if the entire string is the email. (Sentry 2991) 2015-10-09 14:30:08 -07:00
Ben Gotow 83f9f0e4ff fix(specs): ContactStore spec fixes for new contact ranking support 2015-10-09 13:42:24 -07:00
Evan Morikawa a7aec14ca3 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 5a2ddb67d5 fix(auth): Resize the auth window after an update to the token status 2015-10-06 17:58:07 -07:00
Ben Gotow 3896473e3b 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 b38ca54b45 fix(specs): Clean up spec failures due to hot fixes prior to launch 2015-10-05 16:45:30 -07:00
dillon 98e2f5a8c6 fix(NUX): set smaller default window size for users with large monitors
Summary:
fixes T4080

set the maximum default viewport size to 1440x900, the screen resolution for a 15 inch macbook pro.

if the monitor is either wider or taller than the default, then cap the dimension and center it.

Test Plan: added tests

Reviewers: evan, bengotow

Reviewed By: evan, bengotow

Maniphest Tasks: T4080

Differential Revision: https://phab.nylas.com/D2115
2015-10-05 16:24:17 -07:00
Ben Gotow 308c70f53d fix(sync): Request all labels / folders to avoid paging and missing inbox 2015-10-03 23:53:59 -07:00
Ben Gotow db1eae5943 fix(updater): Send UUID and email accounts to enable more specific update distribution 2015-10-03 14:45:39 -07:00
Evan Morikawa 3d20e272ee fix(specs): specs run clean 2015-10-02 18:44:12 -07:00
Evan Morikawa 39266026d1 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 009f07dd2a refactor(dir): move exports to src/global and consolidate tests
Summary:
This:

1. Moves spec-nylas into spec
1. Gets rid of old & irrelevant specs
1. Moves the `vendor` folder (jasmine libs) into the `spec` folder
1. Moves the `exports` folder to `src/global` and updates all references

I pretty extensively made sure the client still works and that all of the
tests pass. The changes should have no effect.

Test Plan: All tests pass!

Reviewers: bengotow, dillon

Differential Revision: https://phab.nylas.com/D2098
2015-10-02 09:19:37 -07:00
Evan Morikawa 137e09eb51 refactor(spec) move spec-nylas to spec 2015-10-01 21:39:44 -07:00
Evan Morikawa 8872a02405 refactor(exports): move exports to src/global 2015-10-01 21:23:37 -07:00
Ben Gotow 1d9a34f5ea rename(Nylas Mail): Replace Nylas Mail > N1 2015-09-29 09:44:30 -07:00
Ben Gotow 899ce2a27a fix(window-serialization): Restore window size, remove cruft from atom.coffee
Summary: Simplify the default window size, restore window size when the main window is loaded, fix serialization of packages in beforeunload.

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2061
2015-09-24 10:40:38 -07:00
Evan Morikawa b761afe960 fix(reply): better coverge for reply-all participants
Summary:
Fixes: T3550
Fixes: T3504

Test Plan: many of them

Reviewers: dillon, bengotow

Reviewed By: dillon, bengotow

Subscribers: mg

Differential Revision: https://phab.nylas.com/D2017
2015-09-14 16:18:55 -04:00
Ben Gotow 95c23ed497 tweak(jasmine): Double timeout in spec runner, see if it makes a difference 2015-09-11 16:16:21 -07:00
dillon 032c8a7c66 fix(thread-list): set min-width to threadlist. fixes T3435.
Summary: fix whitespace

Test Plan: added more test coverage

Reviewers: evan

Reviewed By: evan

Maniphest Tasks: T3435

Differential Revision: https://phab.nylas.com/D1982
2015-09-04 12:27:05 -07:00
Ben Gotow 7190ca69f7 refactor(db): change ID system to have clientIDs and serverIDs
Summary: Major ID refactor

Test Plan: edgehill --test

Reviewers: bengotow, dillon

Differential Revision: https://phab.nylas.com/D1946
2015-08-28 11:24:29 -07:00
Ben Gotow 1a576d92dc feat(work): Create the "Work" window, move TaskQueue, Nylas sync workers
Summary:
Move sync workers and Edgehill token checks to work window

Move the task queue and database setup to the work window

Move ContactStore background refresh to work window

Store the task queue in the database

WIP

The TaskQueue now puts tasks in the database instead of in a file, which also means it can be observed

Move all delta sync and initial sync to a package, make NylasSyncStore which exposes read-only sync state

DraftStore no longer reads task status. Once you set the "sending" bit on a draft, it never gets unset. But that's fine actually.

If your package lists windowTypes, you *only* get loaded in those windowTypes. If you specify no windowTypes, you get loaded in the root window.

This means that onboarding, worker-ui, worker-sync, etc. no longer get loaded into the main window

ActivitySidebar has a special little store that observes the task queue since it's no longer in the window

Move "toggle component regions" / "toggle react remote" to the Developer menu

Move sync worker specs, update draft store specs to not rely on TaskQueue at all

Test Plan: Run existing tests, all pass

Reviewers: dillon, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1936
2015-08-27 16:39:40 -07:00
Ben Gotow 6c407f2f1c fix(config): Apply config change from Atom, process locking
Summary:
d1c44dcb54

Also lock config across processes to prevent the user from being logged out when the main process reads config before it's finished writing. This is what is causing the login window to appear.

Test Plan: Rapidly tap between the two display modes. Note that it no longer reverts to the wrong one intermittently.

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1931
2015-08-25 16:00:09 -07:00
Ben Gotow 81d2edcaf9 feat(accounts): Kill namespaces, long live accounts
Summary:
This diff replaces the Namespace object with the Account object, and changes all references to namespace_id => account_id, etc. The endpoints are now `/threads` instead of `/n/<id>/threads`.

This diff also adds preliminary support for multiple accounts. When you log in, we now log you in to all the attached accounts on edgehill server. From the preferences panel, you can auth with / unlink additional accounts. Shockingly, this all seems to pretty much work.

When replying to a thread, you cannot switch from addresses. However, when creating a new message in a popout composer, you can change the from address and the SaveDraftTask will delete/re-root the draft on the new account.

Search bar doesn't need to do full refresh on clear if it never committed

Allow drafts to be switched to a different account when not in reply to an existing thread

Fix edge case where ChangeMailTask throws exception if no models are modified during performLocal

Show many dots for many accounts in long polling status bar

add/remove accounts from prefs

Spec fixes!

Test Plan: Run tests, none broken!

Reviewers: evan, dillon

Reviewed By: evan, dillon

Differential Revision: https://phab.nylas.com/D1928
2015-08-21 15:29:58 -07:00
Evan Morikawa 3954289cf4 WIP: This is the initial diff for new folders & labels.
Summary:
There are now two objects, Folders & Labels. These inherit from `Category`
(that's what Eben said they were using on the backend).

There are two separate tasks.

1. MoveToFolderTask
2. ApplyLabelsTask

It turns out that the semantics between the two are quite different.
The reverse operation for moving to a folder is a bit tricky.

As of 7-8-15, the Tasks are pretty much complete. I need to write tests
for them still and do some manual testing in the client.

Test Plan: Writing specs

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1724
2015-07-16 11:54:20 -04:00
Ben Gotow 45bb16561f feat(offline-mode, undo-redo): Tasks handle network errors better and retry, undo/redo based on tasks
Summary:
This diff does a couple things:

- Undo redo with a new undo/redo store that maintains it's own queue of undo/redo tasks. This queue is separate from the TaskQueue because not all tasks should be considered for undo history! Right now just the AddRemoveTagsTask is undoable.

- NylasAPI.makeRequest now returns a promise which resolves with the result or rejects with an error. For things that still need them, there's still `success` and `error` callbacks. I also added `started:(req) ->` which allows you to get the underlying request.

- Aborting a NylasAPI request now makes it call it's error callback / promise reject.

- You can now run code after perform local has completed using this syntax:

```
    task = new AddRemoveTagsTask(focused, ['archive'], ['inbox'])
    task.waitForPerformLocal().then ->
      Actions.setFocus(collection: 'thread', item: nextFocus)
      Actions.setCursorPosition(collection: 'thread', item: nextKeyboard)
    Actions.queueTask(task)
```

- In specs, you can now use `advanceClock` to get through a Promise.then/catch/finally. Turns out it was using something low level and not using setTimeout(0).

- The TaskQueue uses promises better and defers a lot of the complexity around queueState for performLocal/performRemote to a task subclass called APITask. APITask implements "perform" and breaks it into "performLocal" and "performRemote".

- All tasks either resolve or reject. They're always removed from the queue, unless they resolve with Task.Status.Retry, which means they internally did a .catch (err) => Promise.resolve(Task.Status.Retry) and they want to be run again later.

- API tasks retry until they succeed or receive a NylasAPI.PermanentErrorCode (400,404,500), in which case they revert and finish.

- The AddRemoveTags Task can now take more than one thread! This is super cool because you can undo/redo a bulk action and also because we'll probably have a bulk tag modification API endpoint soon.

Getting undo / redo working revealed that the thread versioning system we built isn't working because the server was incrementing things by more than 1 at a time. Now we count the number of unresolved "optimistic" changes we've made to a given model, and only accept the server's version of it once the number of optimistic changes is back at zero.

Known Issues:

- AddRemoveTagsTasks aren't dependent on each other, so if you (undo/redo x lots) and then come back online, all the tasks try to add / remove all the tags at the same time. To fix this we can either allow the tasks to be merged together into a minimal set or make them block on each other.

- When Offline, you still get errors in the console for GET requests. Need to catch these and display an offline status bar.

- The metadata tasks haven't been updated yet to the new API. Wanted to get it reviewed first!

Test Plan: All the tests still pass!

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1694
2015-07-07 13:38:53 -04:00
Evan Morikawa 304c34f918 fix(specs): silence noisy specs and fix warnings
Summary:
Silence buffered process spec

Clean up error reporter and spec bootup

fix errors in draft store spec

package manager spec and theme spec fixes

Fix memory leak in draft store

Test Plan: mmmmmm tests. Run all those green passing tests :)

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1628
2015-06-15 18:29:59 -07:00
Evan Morikawa 6fcd5f2ced feat(attachments): new attachments & uploads UI with img support
Summary:
Initial styles on attachments ui

More file uploading UI

fix race condition in draft saving

attachments and uploads interweaved

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1610
2015-06-11 12:04:52 -07:00
Ben Gotow f0f4df6714 add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
Ben Gotow 310f8ba062 fix(mailto): Handle mailto on application launch, populate NamespaceStore synchronously
Summary:
atom-window `sendMessage` was not the same as `browserWindow.webContents.send`. WTF.

Save current namespace to config.cson so that it is never null when window opens

Don't re-create thread view on namespace change unless the namespace has changed

Tests for NamespaceStore state

Push worker immediately in workerForNamcespace to avoid creating two connections per namespace

Allow \n to be put into sreaming buffer, but only one

Clear streaming buffer when we're reconnecting to avoid processing same deltas twice (because of 400msec throttle)

Make `onProcessBuffer` more elegant—No functional changes

Test Plan: Run tests!

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1551
2015-05-21 18:08:29 -07:00
Ben Gotow 92cf2d520c fix(asar): Support ASAR, and running of specs in prod builds
Summary:
fix(task-queue): Repair the findTask function

Add "ship logs" and "open logs" to the developer menu

Patches for Chromium 42

Test Plan: Run tests!

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1547
2015-05-21 14:41:30 -07:00
Ben Gotow 8599bc0397 feat(logging): Developer bar, verbose logging to logstash, Electron 0.26.0
Summary:
- We now make verbose log files continuously as you use the app
- We ship the logs to LogStash via S3 when an exception occurs
- We log the DatabaseStore, ActionBridge and Analytics packages

- We are now on the latest version of Electron 0.26.0
- We are now on Chrome 42 and io.js 1.4.3
- We should be setup to use ASAR soon.

Update atom.sh to reflect that we're now electron

oniguruma was unnecessary

correctly find log files that haven't been shipped yet

Fix a small issue with nodeIsVisible after upgrade to Chrome 42

Delete old logs, better logging from database store, don't ship empty logs

Test Plan: Run existing tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1531
2015-05-19 17:02:46 -07:00
Evan Morikawa 4619871e8d refactor(utils): switch to regular underscore
Summary:
Fixes: T1334

remove final InboxApp references

move out all underscore-plus methods

Mass find and replace of underscore-plus

sed -i '' -- 's/underscore-plus/underscore/g' **/*.coffee
sed -i '' -- 's/underscore-plus/underscore/g' **/*.cjsx

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1534
2015-05-19 16:06:59 -07:00
Ben Gotow 3af6c45387 fix(initial-sync): Make initial sync more robust, show progress, retry on failure
Summary:
Rename ActivityBar => DeveloperBar

Expose sync workers and make them observable

New activity sidebar that replaces momentary notifications

Updated specs

Test Plan: Run new specs!

Reviewers: evan

Reviewed By: evan

Maniphest Tasks: T1131

Differential Revision: https://phab.nylas.com/D1521
2015-05-19 15:59:37 -07:00
Evan Morikawa ab713b5fac refactor(draft): clean up draft store session proxy logic
Summary:
This is an effort to make the logic around the process of sending a draft
cleaner and easier to understand.

Fixes T1253

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Maniphest Tasks: T1253

Differential Revision: https://phab.nylas.com/D1518
2015-05-19 12:07:08 -07:00