Mailspring/exports/nylas-exports.coffee
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

147 lines
5.8 KiB
CoffeeScript

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
# Actions
@load "Actions", 'flux/actions'
# API Endpoints
@load "NylasAPI", 'flux/nylas-api'
@load "EdgehillAPI", 'flux/edgehill-api'
# 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'
@require "Account", 'flux/models/account'
@require "Message", 'flux/models/message'
@require "Contact", 'flux/models/contact'
@require "Calendar", 'flux/models/calendar'
@require "Metadata", 'flux/models/metadata'
@require "LocalLink", 'flux/models/local-link'
@require "DatabaseObjectRegistry", "database-object-registry"
# Exported so 3rd party packages can subclass Model
@load "Model", 'flux/models/model'
@load "Attributes", 'flux/attributes'
# The Task Queue
@require "Task", 'flux/tasks/task'
@require "TaskQueue", 'flux/stores/task-queue'
@require "TaskRegistry", "task-registry"
@require "UndoRedoStore", 'flux/stores/undo-redo-store'
# Tasks
# 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'
@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'
# 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'
@require "AccountStore", 'flux/stores/account-store'
@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'
@require "FocusedCategoryStore", 'flux/stores/focused-category-store'
@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'
# Utils
@load "Utils", 'flux/models/utils'
@load "DOMUtils", 'dom-utils'
@load "CanvasUtils", 'canvas-utils'
@load "RegExpUtils", 'regexp-utils'
@load "MessageUtils", 'flux/models/message-utils'
# Services
@load "UndoManager", 'flux/undo-manager'
@load "QuotedHTMLParser", 'services/quoted-html-parser'
@load "QuotedPlainTextParser", 'services/quoted-plain-text-parser'
# Errors
@get "APIError", -> require('../src/flux/errors').APIError
@get "OfflineError", -> require('../src/flux/errors').OfflineError
@get "TimeoutError", -> require('../src/flux/errors').TimeoutError
# Process Internals
@load "LaunchServices", 'launch-services'
@load "BufferedProcess", 'buffered-process'
@load "BufferedNodeProcess", 'buffered-node-process'
# Testing
@get "NylasTestUtils", -> require '../spec-nylas/test_utils'
module.exports = NylasExports