Mailspring/spec-nylas
Evan Morikawa cd9ccd85e2 refactor(DB): promisify database
Summary:
WIP. The app launches and works for me. I still need to fix the tests
just the DB ones though :D

I changed the `DatabaseProxy` into a `DatabaseConnection` object. It will
request a fully instantiated databse from the backend Browser.

If we're already setup, it'll connect straight to the existing DB.

If we're not setup, then it'll create a new database and run the inital
schema migration on it. The `_createNewDatabase` promise won't resolve
until the migration has run.

Until we add in a more sophisticated migration system and get rid of the
stupid `modelClassMap` that's shoved in `Utils`, I'm passing in a series
of `_setupQueries()` to get everything started.

The `DatabaseConnection` is also the one responsible for queuing up
queries until the DB is fully populated and ready to go.

We actually get a lot of queries before we're setup because a lot of
Stores will make DB requests on `require` in their `constructor` or `init`
methods. (remember all the times we call `_populateStore` in `init`).

Now those queries are aggregated by the `DatabaseConnection` and then
executed sequentially.

Our methods like `persistModel` now resolve only after both the queries
have completed AND their corresponding `triggerLater` has completed as
well.

Test Plan: in progress

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1688
2015-06-26 07:42:41 -07:00
..
components fix(thread-list): Narrow mode, and new selection rules for three-pane 2015-06-11 18:00:40 -07:00
fixtures refactor(DB): promisify database 2015-06-26 07:42:41 -07:00
models refactor(utils): switch to regular underscore 2015-05-19 16:06:59 -07:00
stores refactor(DB): promisify database 2015-06-26 07:42:41 -07:00
tasks fix(T1886): When sending, strip off fields if they result in specific, known errors on the API 2015-06-15 18:19:52 -07:00
action-bridge-spec.coffee feat(logging): Developer bar, verbose logging to logstash, Electron 0.26.0 2015-05-19 17:02:46 -07:00
auto-update-manager-spec.coffee feat(update): autoupdater adds an updateLevel param 2015-06-11 12:23:31 -07:00
buffered-process-spec.coffee fix(tests): remove unnecessary failing test 2015-06-16 09:53:27 -07:00
clipboard-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
component-registry-spec.coffee feat(*): draft icon, misc fixes, and WorkspaceStore / custom toolbar in secondary windows 2015-06-03 16:02:19 -07:00
database-view-spec.coffee perf(thread-list): Tailored SQLite indexes, ListTabular / ScrollRegion optimizations galore 2015-06-17 20:12:48 -07:00
menu-manager-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
model-view-selection-spec.coffee fix(selection): Fix issue where selecting offscreen thread (null) could break selection 2015-06-01 18:29:39 -07:00
model-view-spec.coffee refactor(utils): switch to regular underscore 2015-05-19 16:06:59 -07:00
module-cache-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
nylas-protocol-handler-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
nylas-sync-worker-spec.coffee fix(specs): silence noisy specs and fix warnings 2015-06-15 18:29:59 -07:00
package-manager-spec.coffee fix(test): remove bad nondeterministic package spec 2015-06-17 20:49:06 -07:00
package-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
style-manager-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
styles-element-spec.coffee add(specs): +101 specs and 403 assertions from Atom 2015-06-02 19:51:00 -07:00
task-spec.coffee fix(build): Temporarily disable 'Task' tests Jenkins can't run, and avoid empty ui-variables files 2015-06-03 12:04:43 -07:00
test_utils.coffee fix(asar): Support ASAR, and running of specs in prod builds 2015-05-21 14:41:30 -07:00
theme-manager-spec.coffee fix(specs): silence noisy specs and fix warnings 2015-06-15 18:29:59 -07:00
undo-manager-spec.coffee fix(composer): polish composer edge cases 2015-05-19 16:12:39 -07:00
utils-spec.coffee refactor(utils): switch to regular underscore 2015-05-19 16:06:59 -07:00