2015-08-20 07:25:56 +08:00
|
|
|
Task = null
|
|
|
|
Model = null
|
|
|
|
TaskRegistry = null
|
|
|
|
DatabaseObjectRegistry = null
|
|
|
|
|
|
|
|
class NylasExports
|
|
|
|
@registerSerializable = (exported) ->
|
|
|
|
if exported.prototype
|
|
|
|
Task ?= require '../src/flux/tasks/task'
|
|
|
|
Model ?= require '../src/flux/models/model'
|
|
|
|
if exported.prototype instanceof Model
|
|
|
|
DatabaseObjectRegistry ?= require '../src/database-object-registry'
|
|
|
|
DatabaseObjectRegistry.register(exported)
|
|
|
|
else if exported.prototype instanceof Task
|
|
|
|
TaskRegistry ?= require '../src/task-registry'
|
|
|
|
TaskRegistry.register(exported)
|
|
|
|
|
|
|
|
@get = (prop, get) ->
|
|
|
|
Object.defineProperty @, prop, {get, enumerable: true}
|
|
|
|
|
|
|
|
# Will lazy load when requested
|
|
|
|
@load = (prop, path) ->
|
|
|
|
Object.defineProperty @, prop,
|
|
|
|
get: ->
|
|
|
|
exported = require "../src/#{path}"
|
|
|
|
NylasExports.registerSerializable(exported)
|
|
|
|
return exported
|
|
|
|
enumerable: true
|
|
|
|
|
|
|
|
# Will require immediately
|
|
|
|
@require = (prop, path) ->
|
|
|
|
exported = require "../src/#{path}"
|
|
|
|
NylasExports.registerSerializable(exported)
|
|
|
|
@[prop] = exported
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# Actions
|
|
|
|
@load "Actions", 'flux/actions'
|
2015-04-25 00:36:19 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# API Endpoints
|
|
|
|
@load "NylasAPI", 'flux/nylas-api'
|
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-28 07:39:40 +08:00
|
|
|
@load "NylasSyncStatusStore", 'flux/stores/nylas-sync-status-store'
|
2015-08-20 07:25:56 +08:00
|
|
|
@load "EdgehillAPI", 'flux/edgehill-api'
|
2015-02-21 04:24:15 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# The Database
|
|
|
|
@load "ModelView", 'flux/stores/model-view'
|
|
|
|
@load "SearchView", 'flux/stores/search-view'
|
|
|
|
@load "DatabaseView", 'flux/stores/database-view'
|
|
|
|
@load "DatabaseStore", 'flux/stores/database-store'
|
|
|
|
|
|
|
|
# Database Objects
|
|
|
|
# These need to be required immeidatley to populated the
|
|
|
|
# DatabaseObjectRegistry so we know what Database Tables to construct
|
|
|
|
@require "File", 'flux/models/file'
|
|
|
|
@require "Event", 'flux/models/event'
|
|
|
|
@require "Label", 'flux/models/label'
|
|
|
|
@require "Folder", 'flux/models/folder'
|
|
|
|
@require "Thread", 'flux/models/thread'
|
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-22 06:29:58 +08:00
|
|
|
@require "Account", 'flux/models/account'
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "Message", 'flux/models/message'
|
|
|
|
@require "Contact", 'flux/models/contact'
|
2015-09-01 06:38:08 +08:00
|
|
|
@require "Category", 'flux/models/category'
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "Calendar", 'flux/models/calendar'
|
|
|
|
@require "Metadata", 'flux/models/metadata'
|
|
|
|
@require "DatabaseObjectRegistry", "database-object-registry"
|
2015-09-05 03:23:15 +08:00
|
|
|
@require "MailViewFilter", 'mail-view-filter'
|
2015-08-20 07:25:56 +08:00
|
|
|
|
|
|
|
# Exported so 3rd party packages can subclass Model
|
|
|
|
@load "Model", 'flux/models/model'
|
|
|
|
@load "Attributes", 'flux/attributes'
|
2015-04-23 07:41:29 +08:00
|
|
|
|
2015-02-21 04:24:15 +08:00
|
|
|
# The Task Queue
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "Task", 'flux/tasks/task'
|
|
|
|
@require "TaskRegistry", "task-registry"
|
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-28 07:39:40 +08:00
|
|
|
@require "TaskQueue", 'flux/stores/task-queue'
|
|
|
|
@load "TaskQueueStatusStore", 'flux/stores/task-queue-status-store'
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "UndoRedoStore", 'flux/stores/undo-redo-store'
|
2015-02-21 04:24:15 +08:00
|
|
|
|
2015-05-01 02:35:38 +08:00
|
|
|
# Tasks
|
2015-08-20 07:25:56 +08:00
|
|
|
# These need to be required immediately to populate the TaskRegistry so
|
|
|
|
# we know how to deserialized saved or IPC-sent tasks.
|
|
|
|
@require "EventRSVP", 'flux/tasks/event-rsvp'
|
|
|
|
@require "SendDraftTask", 'flux/tasks/send-draft'
|
|
|
|
@require "FileUploadTask", 'flux/tasks/file-upload-task'
|
|
|
|
@require "DestroyDraftTask", 'flux/tasks/destroy-draft'
|
|
|
|
@require "ChangeLabelsTask", 'flux/tasks/change-labels-task'
|
|
|
|
@require "ChangeFolderTask", 'flux/tasks/change-folder-task'
|
2015-09-11 01:34:09 +08:00
|
|
|
@require "SyncbackCategoryTask", 'flux/tasks/syncback-category-task'
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "ChangeUnreadTask", 'flux/tasks/change-unread-task'
|
|
|
|
@require "SyncbackDraftTask", 'flux/tasks/syncback-draft'
|
|
|
|
@require "ChangeStarredTask", 'flux/tasks/change-starred-task'
|
|
|
|
@require "CreateMetadataTask", 'flux/tasks/create-metadata-task'
|
|
|
|
@require "MarkMessageReadTask", 'flux/tasks/mark-message-read'
|
|
|
|
@require "ArchiveThreadHelper", 'flux/tasks/archive-thread-helper'
|
|
|
|
@require "DestroyMetadataTask", 'flux/tasks/destroy-metadata-task'
|
2015-02-21 04:24:15 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# Stores
|
|
|
|
# These need to be required immediately since some Stores are
|
|
|
|
# listen-only and not explicitly required from anywhere. Stores
|
|
|
|
# currently set themselves up on require.
|
|
|
|
@require "EventStore", 'flux/stores/event-store'
|
|
|
|
@require "DraftStore", 'flux/stores/draft-store'
|
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-22 06:29:58 +08:00
|
|
|
@require "AccountStore", 'flux/stores/account-store'
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "MessageStore", 'flux/stores/message-store'
|
|
|
|
@require "ContactStore", 'flux/stores/contact-store'
|
|
|
|
@require "CategoryStore", 'flux/stores/category-store'
|
|
|
|
@require "MetadataStore", 'flux/stores/metadata-store'
|
|
|
|
@require "AnalyticsStore", 'flux/stores/analytics-store'
|
|
|
|
@require "WorkspaceStore", 'flux/stores/workspace-store'
|
|
|
|
@require "DraftCountStore", 'flux/stores/draft-count-store'
|
|
|
|
@require "FileUploadStore", 'flux/stores/file-upload-store'
|
|
|
|
@require "UnreadCountStore", 'flux/stores/unread-count-store'
|
|
|
|
@require "FileDownloadStore", 'flux/stores/file-download-store'
|
|
|
|
@require "DraftStoreExtension", 'flux/stores/draft-store-extension'
|
|
|
|
@require "FocusedContentStore", 'flux/stores/focused-content-store'
|
2015-09-05 03:23:15 +08:00
|
|
|
@require "FocusedMailViewStore", 'flux/stores/focused-mail-view-store'
|
2015-08-20 07:25:56 +08:00
|
|
|
@require "FocusedContactsStore", 'flux/stores/focused-contacts-store'
|
|
|
|
@require "MessageBodyProcessor", 'flux/stores/message-body-processor'
|
|
|
|
@require "MessageStoreExtension", 'flux/stores/message-store-extension'
|
|
|
|
|
|
|
|
# React Components
|
|
|
|
@get "React", -> require 'react' # Our version of React for 3rd party use
|
|
|
|
@load "ReactRemote", 'react-remote/react-remote-parent'
|
|
|
|
@load "ComponentRegistry", 'component-registry'
|
|
|
|
@load "PriorityUICoordinator", 'priority-ui-coordinator'
|
2015-02-21 04:24:15 +08:00
|
|
|
|
|
|
|
# Utils
|
2015-08-20 07:25:56 +08:00
|
|
|
@load "Utils", 'flux/models/utils'
|
|
|
|
@load "DOMUtils", 'dom-utils'
|
|
|
|
@load "CanvasUtils", 'canvas-utils'
|
|
|
|
@load "RegExpUtils", 'regexp-utils'
|
|
|
|
@load "MessageUtils", 'flux/models/message-utils'
|
2015-03-03 07:33:58 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# Services
|
|
|
|
@load "UndoManager", 'flux/undo-manager'
|
|
|
|
@load "QuotedHTMLParser", 'services/quoted-html-parser'
|
|
|
|
@load "QuotedPlainTextParser", 'services/quoted-plain-text-parser'
|
fix(drafts): Various improvements and fixes to drafts, draft state management
Summary:
This diff contains a few major changes:
1. Scribe is no longer used for the text editor. It's just a plain contenteditable region. The toolbar items (bold, italic, underline) still work. Scribe was causing React inconcistency issues in the following scenario:
- View thread with draft, edit draft
- Move to another thread
- Move back to thread with draft
- Move to another thread. Notice that one or more messages from thread with draft are still there.
There may be a way to fix this, but I tried for hours and there are Github Issues open on it's repository asking for React compatibility, so it may be fixed soon. For now contenteditable is working great.
2. Action.saveDraft() is no longer debounced in the DraftStore. Instead, firing that action causes the save to happen immediately, and the DraftStoreProxy has a new "DraftChangeSet" class which is responsbile for batching saves as the user interacts with the ComposerView. There are a couple big wins here:
- In the future, we may want to be able to call Action.saveDraft() in other situations and it should behave like a normal action. We may also want to expose the DraftStoreProxy as an easy way of backing interactive draft UI.
- Previously, when you added a contact to To/CC/BCC, this happened:
<input> -> Action.saveDraft -> (delay!!) -> Database -> DraftStore -> DraftStoreProxy -> View Updates
Increasing the delay to something reasonable like 200msec meant there was 200msec of lag before you saw the new view state.
To fix this, I created a new class called DraftChangeSet which is responsible for accumulating changes as they're made and firing Action.saveDraft. "Adding" a change to the change set also causes the Draft provided by the DraftStoreProxy to change immediately (the changes are a temporary layer on top of the database object). This means no delay while changes are being applied. There's a better explanation in the source!
This diff includes a few minor fixes as well:
1. Draft.state is gone—use Message.object = draft instead
2. String model attributes should never be null
3. Pre-send checks that can cancel draft send
4. Put the entire curl history and task queue into feedback reports
5. Cache localIds for extra speed
6. Move us up to latest React
Test Plan: No new tests - once we lock down this new design I'll write tests for the DraftChangeSet
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1125
2015-02-04 08:24:31 +08:00
|
|
|
|
2015-04-25 00:36:19 +08:00
|
|
|
# Errors
|
2015-08-20 07:25:56 +08:00
|
|
|
@get "APIError", -> require('../src/flux/errors').APIError
|
|
|
|
@get "OfflineError", -> require('../src/flux/errors').OfflineError
|
|
|
|
@get "TimeoutError", -> require('../src/flux/errors').TimeoutError
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# Process Internals
|
|
|
|
@load "LaunchServices", 'launch-services'
|
|
|
|
@load "BufferedProcess", 'buffered-process'
|
|
|
|
@load "BufferedNodeProcess", 'buffered-node-process'
|
2015-07-09 00:51:33 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
# Testing
|
|
|
|
@get "NylasTestUtils", -> require '../spec-nylas/test_utils'
|
2015-04-01 08:19:17 +08:00
|
|
|
|
2015-08-20 07:25:56 +08:00
|
|
|
module.exports = NylasExports
|