Commit graph

38 commits

Author SHA1 Message Date
Ben Gotow aa58743b38 fix(drafts): Fix syncback issue caused by bad Account database query 2015-09-29 12:14:11 -07:00
Ben Gotow 5f1b909cae fix(change-mail-task): Limit the parallelism of API requests via change mail task
No you can't make 1,100 API requests at the same time. Thanks. New specs to make sure there aren't any regressions in this behavior.
2015-09-27 23:42:43 -07:00
Evan Morikawa 61eec6b21a fix(database): add DatabaseStore.atomically to handle read/write issues
Summary:
Fixes T3566
Fixes T3567

Test Plan: new tests

Reviewers: dillon, bengotow

Reviewed By: bengotow

Maniphest Tasks: T3566, T3567

Differential Revision: https://phab.nylas.com/D2025
2015-09-15 20:27:52 -04:00
dillon 8f71cee43b feat(categories): enable creating new labels and folders. addresses T3351.
Summary:
write tests for adding/removing existing labels and popover closing

add more tests

address code review comments

fix the tests

add test for creating label

add test for creating label and queueing change label task

add test for creating a folder

add syncback category task spec

make the rest of the tests pass

remove unnecessary parens

add a few more tests

add last test

Test Plan: added some tests. all tests green

Reviewers: bengotow, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2010
2015-09-10 10:34:09 -07:00
Evan Morikawa 4080f63907 fix(syncback): Handle synback errors better
Fixes "Cannot read property "method" of undefined in SyncbackDraftTest.
Now with more specs!
2015-09-09 11:44:36 -07:00
Evan Morikawa 395bd80da2 fix(draft-list): draft list removes draft when the message sends
Summary:
This started when I noticed that drafts weren't dissapearing from the
draft list after send. This was a pretty big bug because if you ever
clicked on one again and tried to re-send it would throw a 400 error
saying the draft id doesn't exist.

This uncovered a few fundamental issues with the DB.

First of all, the reason the draft list wasn't updating was because the DB
trigger that happened when we got in a new message, was being ignored
since the diff contained no drafts (it's now a message).

The bigger issue was that if you had a draft with only a clientId, gave it
a serverId, and tried to call "save", the REPLACE INTO method would not
update the old object, but rather create a second duplicate. This is
because the `id` field was being used as the PRIMARY KEY, and in this
case, that `id` field changed! The fix was to change the PRIMARY KEY to be
the `cilent_id` instead of the `id` and use that as the REPLACE INTO
index.

We still need the `id` field; however, because all of our reads depend on
that field usually being the serverId

Fixes T3507

Test Plan: See new and updated tests

Reviewers: dillon, bengotow

Reviewed By: bengotow

Maniphest Tasks: T3507

Differential Revision: https://phab.nylas.com/D1992
2015-09-08 13:11:34 -07:00
Evan Morikawa e95cc44418 fix(draft): remove old local draft after sending
Fixes T3507
2015-09-06 18:59:07 -07:00
Evan Morikawa 553e2bde2f feat(draft): drafts that fail to send throw better errors
Summary: Also enhancements to the developer toolbar

Test Plan: edgehill --test

Reviewers: dillon, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1976
2015-09-03 16:29:33 -07:00
Evan Morikawa 269b35ebca fix(specs): fix file upload specs 2015-08-31 18:37:45 -07:00
Ben Gotow ad4bc1c7ac fix(file-uploads): Do not store the draft session and draft during upload 2015-08-30 20:17:16 -07:00
Evan Morikawa 75e8eddbb6 fix(uploads): no more from picker & uploads use correct accountId
Test Plan: edgehill --test

Reviewers: dillon, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1955
2015-08-28 20:35:43 -04:00
Ben Gotow 07583d6f11 fix(send-draft): Update the draft rather so it's clientId is maintained, even if the ID has changed on send 2015-08-28 13:19:09 -07:00
Ben Gotow 944a5838d8 fix(specs): Future specs should stub DatabaseStore.run, not find/findBy 2015-08-28 12:41:56 -07:00
Ben Gotow f8c5f7b967 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 be6c5b1d11 fix(change-mail-task): Ignore 404s when changing mail so that we don't attempt to roll back and re-create purged objects + spec 2015-08-26 11:54:03 -07:00
Ben Gotow c639b85fad fix(object-serialization): Constrain use of __constructorName, fix infinite recursion, remove hackiness 2015-08-21 16:08:24 -07:00
Ben Gotow 607ca3bf10 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 d2b979e716 refactor(models): Enables 3rd party plugins to add Models & Tasks
Summary:
Adding serialzable registry

Added DatabaseObjectRegistry

rename modelReviver to deserializeObject

Consolidate deserizlie

Get rid of model methods from Utils

DatabaseRegistry change notifications

Logic to throttle database refresh requests

Fixes in nylas-exports

Silent model setup

Continue to resolving the database setup phase for non main windows.

A packages `activate` method does not actually get called until the
DatabaseStore says that it's ready. This is necessary to ensure that a
package that introduces database changes has those schema changes take
hold before the activate happens.

However, in windows like the `onboarding` window that do not depend on a
database at all, there is no setup that is run and the promise use to
never resolve thereby making the packages never activate.

In this case, any external windows will go ahead and let their packages
activate.

Check subclass instead of instance!

Use the correct types for "messages" and "drafts"

Move Salesforce models

Proper references to Model and Attributes

Convert Salesforce stores to NylasStores and fix paths

Move database setup to DB

Test Plan: todo

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1899
2015-08-19 16:25:56 -07:00
Ben Gotow f3bea721e7 fix(labels/folders): Temporarily disable changing nested messages
- It's slow, and causes performLocal to take much longer
- It's making changes we receive from the streaming API a few moments later
- We don't actually display nested folder data anywhere important
2015-08-05 17:39:48 -07:00
Ben Gotow 7f94680550 perf(*): Add indexes, optimize "shouldAcceptModel", optimize Tasks
Summary:
Consolidate the smarts from ChangeFolderTask into a generic ChangeMailTask

ChangeMailTask:
   - only makes requests for threads / messages that actually changed
   - handles incrementing / decrementing locks
   - writes changes to the database in a single pass, and only writes modified models
   - encapsulates the undo state that was built into ChangeFolderTask

This change means that ChangeLabelsTask enjoys the same "smarts" as ChangeFolderTask. Label changes resulting in no-ops do not create web requests, you can undo label changes and they go back to the correct previous state.

Replace "UpdateThreadsTask" and "UpdateNylasObjectsTask" with subclasses based on the same code used for folder/labels

This means that the naming and parameter sets are consistent for all thread/message changing tasks. It also means that starring/marking as use the same (tested) business logic and starring 999 already-starred threads doesn't create 999 requests.
Go away DraftCountStore - nobody wants you in secondary windows

Add "Debug query plans" option which prints out the steps the database is taking. Look for "SCAN" to now you're having a bad time.

Make "version" field queryable, when we receive deltas/API response, find all versions of existing models in a single query without loading or parsing the objects

Contact: Add index for lookup by email

Label: add index for lookup by name

Message: Add index for message body join table

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1840
2015-08-05 15:53:08 -07:00
Evan Morikawa d984071ac7 fix(folder): specs and fixes to ChangeFolderTask
Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1834
2015-08-03 19:09:41 -07:00
Ben Gotow 3a947ccf54 fix(undo-redo): Minor tweaks to undo/redo based on testing - see description
Summary:
Give UpdateThreadsTask a description method for strings like "Marked as read"

Give ChangeLabelsTask a better description method that returns shorter strings and is specific when possible

Give ChangeFolderTask a more specific description and don't assume folderOrId will always be a folder

Make it so that passive "mark as read" from the message store isn't undoable

Give the base class a description method that names the object

Change UndoRedo component CSS a bit:

- Use "inline-flexbox" with a max-width so that we can define shrinking rules on the label and Undo button (label gets ellipsis, button does not shrink at all)

- Avoid left:39%, since it assumed that the undo-redo element would be 22% of the width of the thread list, which wasn't always true. Instead, make the `undo-redo-manager` container "text-align:center", so the `undo-redo` div is always centered within it.

- Add `cursor:default` so that the user sees the pointer, not the text insertion cursor when hovering over "Undo"

- Add overflow / text-overflow so that if the message is ever too long, the user sees `...` ellipsis properly.

Test Plan: Run a few new tests

Reviewers: evan, ethanb

Reviewed By: ethanb

Differential Revision: https://phab.nylas.com/D1830
2015-08-03 14:46:19 -07:00
Ben Gotow 17c00c0e54 fix(change-category): Redefine objectIds when objects cannot be found
Fixes https://sentry.nylas.com/sentry/edgehill/group/1717/
2015-08-03 11:38:57 -07:00
Evan Morikawa e050c198d9 test(folders): adding specs for changing folders and labels
Summary:
ChangeLabelsTask specs

adding change folders task

Adding tests for ChangeFolderTask

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1806
2015-08-03 10:16:46 -07:00
EthanBlackburn 6609fe272c RSVP tile for events on messages
Summary: RSVP tile now appears for messages with attached events.

Test Plan: Tested manually. Will add unit tests

Reviewers: evan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1797
2015-07-28 18:21:30 -07:00
Ben Gotow 2f6092d342 feat(draft-syncback): Sync drafts with Gmail (API does not support Exchange syncback)
Summary:
Sync drafts not files

WIP

Test Plan: Run syncback task specs

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1772
2015-07-22 11:18:23 -07:00
Evan Morikawa 00c74cd1a9 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 e6881573d9 fix(file-uploads): Smattering of bug fixes related to uploading & canceling uploads
Summary:
Cancelling a file upload properly makes the task return Task.Status.Finished (previously it was broken and returning Task.Status.Retry)

Dragging a directory now gives you a nice error message

Aborting an upload now looks for the task with the given ID, not a task with the given filepath since there could be identical uploads happening in other windows

Make it more explicit that the uploadId is not the task ID

Add a few tests

Test Plan: Run new tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1750
2015-07-15 16:52:43 -07:00
Ben Gotow 343bb3163b 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
Ben Gotow 0089fcac2a fix(T1886): When sending, strip off fields if they result in specific, known errors on the API
Summary: Fixes T1886

Test Plan: Run 2 new tests

Reviewers: evan

Reviewed By: evan

Maniphest Tasks: T1886

Differential Revision: https://phab.nylas.com/D1633
2015-06-15 18:19:52 -07:00
Evan Morikawa 449e11cdda 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
Evan Morikawa 5e4fea01e5 Fixes T1363: move file success to task and listen to DB event
Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Maniphest Tasks: T1363

Differential Revision: https://phab.nylas.com/D1548
2015-05-21 13:43:14 -07:00
Evan Morikawa fc4b3b56d7 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 0efdec5fd5 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 ae41c94e42 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
Ben Gotow e96f242121 InboxAPI => NylasAPI 2015-05-15 11:12:03 -07:00
Ben Gotow 7abf5a480b Move atom.inbox => {NylasAPI} = require 'nylas-exports'
Conflicts:
	spec-nylas/tasks/file-upload-task-spec.coffee
2015-05-15 11:09:24 -07:00
Ben Gotow 9378f4480c fix(naming): Move atom/inbox/nilas refs to Nylas
Conflicts:
	internal_packages/inbox-activity-bar/lib/activity-bar-long-poll-item.cjsx
2015-05-15 11:07:28 -07:00