From bd9983005cda6a2f0d12da77cdc4d4b2010d0601 Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Sun, 25 Jun 2017 01:04:02 -0700 Subject: [PATCH] Remove deprecations still supported by client --- .../build/resources/asar-ordering-hint.txt | 3 - .../account-sidebar.less | 0 .../category-picker.less | 0 .../composer-emoji.less | 0 .../{stylesheets => styles}/index.less | 0 .../message-templates.less | 0 .../{stylesheets => styles}/translate.less | 0 .../{stylesheets => styles}/composer.less | 0 .../{stylesheets => styles}/fonts.less | 0 .../{stylesheets => styles}/draft-list.less | 0 .../{stylesheets => styles}/events.less | 0 .../sidebar-github-profile.less | 0 .../main-calendar.less | 0 .../message-autoload-images.less | 0 .../find-in-thread.less | 0 .../{stylesheets => styles}/message-list.less | 0 .../{stylesheets => styles}/github.less | 0 .../{stylesheets => styles}/mode-switch.less | 0 .../notifications.less | 0 .../{stylesheets => styles}/styles.less | 0 .../onboarding-reset.less | 0 .../{stylesheets => styles}/onboarding.less | 0 .../participant-profile.less | 0 .../{stylesheets => styles}/main.less | 0 .../{stylesheets => styles}/index.less | 0 .../{stylesheets => styles}/phishing.less | 0 .../{stylesheets => styles}/plugins.less | 0 .../preferences-accounts.less | 0 .../preferences-identity.less | 0 .../preferences-mail-rules.less | 0 .../{stylesheets => styles}/preferences.less | 0 .../selected-items-stack.less | 0 .../{stylesheets => styles}/thread-list.less | 0 .../lib/search-query-subscription.es6 | 61 +++-- .../thread-search-bar.less | 0 .../snooze-feature-used-modal.less | 0 .../snooze-mail-label.less | 0 .../snooze-popover.less | 0 .../registries/extension-registry-spec.coffee | 8 - .../client-app/src/deprecate-utils.coffee | 30 --- packages/client-app/src/flux/nylas-api.es6 | 2 - .../src/flux/nylas-long-connection.es6 | 246 ------------------ .../src/flux/stores/message-store.coffee | 31 --- .../src/global/nylas-component-kit.coffee | 9 - .../client-app/src/global/nylas-exports.es6 | 23 -- .../src/registries/extension-registry.es6 | 10 +- packages/client-app/src/theme-manager.coffee | 6 +- 47 files changed, 34 insertions(+), 395 deletions(-) rename packages/client-app/internal_packages/account-sidebar/{stylesheets => styles}/account-sidebar.less (100%) rename packages/client-app/internal_packages/category-picker/{stylesheets => styles}/category-picker.less (100%) rename packages/client-app/internal_packages/composer-emoji/{stylesheets => styles}/composer-emoji.less (100%) rename packages/client-app/internal_packages/composer-markdown/{stylesheets => styles}/index.less (100%) rename packages/client-app/internal_packages/composer-templates/{stylesheets => styles}/message-templates.less (100%) rename packages/client-app/internal_packages/composer-translate/{stylesheets => styles}/translate.less (100%) rename packages/client-app/internal_packages/composer/{stylesheets => styles}/composer.less (100%) rename packages/client-app/internal_packages/custom-fonts/{stylesheets => styles}/fonts.less (100%) rename packages/client-app/internal_packages/draft-list/{stylesheets => styles}/draft-list.less (100%) rename packages/client-app/internal_packages/events/{stylesheets => styles}/events.less (100%) rename packages/client-app/internal_packages/github-contact-card/{stylesheets => styles}/sidebar-github-profile.less (100%) rename packages/client-app/internal_packages/main-calendar/{stylesheets => styles}/main-calendar.less (100%) rename packages/client-app/internal_packages/message-autoload-images/{stylesheets => styles}/message-autoload-images.less (100%) rename packages/client-app/internal_packages/message-list/{stylesheets => styles}/find-in-thread.less (100%) rename packages/client-app/internal_packages/message-list/{stylesheets => styles}/message-list.less (100%) rename packages/client-app/internal_packages/message-view-on-github/{stylesheets => styles}/github.less (100%) rename packages/client-app/internal_packages/mode-switch/{stylesheets => styles}/mode-switch.less (100%) rename packages/client-app/internal_packages/notifications/{stylesheets => styles}/notifications.less (100%) rename packages/client-app/internal_packages/notifications/{stylesheets => styles}/styles.less (100%) rename packages/client-app/internal_packages/onboarding/{stylesheets => styles}/onboarding-reset.less (100%) rename packages/client-app/internal_packages/onboarding/{stylesheets => styles}/onboarding.less (100%) rename packages/client-app/internal_packages/participant-profile/{stylesheets => styles}/participant-profile.less (100%) rename packages/client-app/internal_packages/personal-level-indicators/{stylesheets => styles}/main.less (100%) rename packages/client-app/internal_packages/phishing-detection/{stylesheets => styles}/index.less (100%) rename packages/client-app/internal_packages/phishing-detection/{stylesheets => styles}/phishing.less (100%) rename packages/client-app/internal_packages/plugins/{stylesheets => styles}/plugins.less (100%) rename packages/client-app/internal_packages/preferences/{stylesheets => styles}/preferences-accounts.less (100%) rename packages/client-app/internal_packages/preferences/{stylesheets => styles}/preferences-identity.less (100%) rename packages/client-app/internal_packages/preferences/{stylesheets => styles}/preferences-mail-rules.less (100%) rename packages/client-app/internal_packages/preferences/{stylesheets => styles}/preferences.less (100%) rename packages/client-app/internal_packages/thread-list/{stylesheets => styles}/selected-items-stack.less (100%) rename packages/client-app/internal_packages/thread-list/{stylesheets => styles}/thread-list.less (100%) rename packages/client-app/internal_packages/thread-search/{stylesheets => styles}/thread-search-bar.less (100%) rename packages/client-app/internal_packages/thread-snooze/{stylesheets => styles}/snooze-feature-used-modal.less (100%) rename packages/client-app/internal_packages/thread-snooze/{stylesheets => styles}/snooze-mail-label.less (100%) rename packages/client-app/internal_packages/thread-snooze/{stylesheets => styles}/snooze-popover.less (100%) delete mode 100644 packages/client-app/src/deprecate-utils.coffee delete mode 100644 packages/client-app/src/flux/nylas-long-connection.es6 diff --git a/packages/client-app/build/resources/asar-ordering-hint.txt b/packages/client-app/build/resources/asar-ordering-hint.txt index 5df6de07c..680f0d144 100644 --- a/packages/client-app/build/resources/asar-ordering-hint.txt +++ b/packages/client-app/build/resources/asar-ordering-hint.txt @@ -1036,11 +1036,8 @@ 3662409: src/nylas-spellchecker.js 3798011: src/global/nylas-exports.js 3798011: src/global/nylas-exports.js -5912469: src/deprecate-utils.js 3668481: src/config-schema.js -5912469: src/deprecate-utils.js 3798011: src/global/nylas-exports.js -5912469: src/deprecate-utils.js 3668481: src/config-schema.js 4687050: src/global/nylas-observables.js 4697858: node_modules/rx-lite/package.json diff --git a/packages/client-app/internal_packages/account-sidebar/stylesheets/account-sidebar.less b/packages/client-app/internal_packages/account-sidebar/styles/account-sidebar.less similarity index 100% rename from packages/client-app/internal_packages/account-sidebar/stylesheets/account-sidebar.less rename to packages/client-app/internal_packages/account-sidebar/styles/account-sidebar.less diff --git a/packages/client-app/internal_packages/category-picker/stylesheets/category-picker.less b/packages/client-app/internal_packages/category-picker/styles/category-picker.less similarity index 100% rename from packages/client-app/internal_packages/category-picker/stylesheets/category-picker.less rename to packages/client-app/internal_packages/category-picker/styles/category-picker.less diff --git a/packages/client-app/internal_packages/composer-emoji/stylesheets/composer-emoji.less b/packages/client-app/internal_packages/composer-emoji/styles/composer-emoji.less similarity index 100% rename from packages/client-app/internal_packages/composer-emoji/stylesheets/composer-emoji.less rename to packages/client-app/internal_packages/composer-emoji/styles/composer-emoji.less diff --git a/packages/client-app/internal_packages/composer-markdown/stylesheets/index.less b/packages/client-app/internal_packages/composer-markdown/styles/index.less similarity index 100% rename from packages/client-app/internal_packages/composer-markdown/stylesheets/index.less rename to packages/client-app/internal_packages/composer-markdown/styles/index.less diff --git a/packages/client-app/internal_packages/composer-templates/stylesheets/message-templates.less b/packages/client-app/internal_packages/composer-templates/styles/message-templates.less similarity index 100% rename from packages/client-app/internal_packages/composer-templates/stylesheets/message-templates.less rename to packages/client-app/internal_packages/composer-templates/styles/message-templates.less diff --git a/packages/client-app/internal_packages/composer-translate/stylesheets/translate.less b/packages/client-app/internal_packages/composer-translate/styles/translate.less similarity index 100% rename from packages/client-app/internal_packages/composer-translate/stylesheets/translate.less rename to packages/client-app/internal_packages/composer-translate/styles/translate.less diff --git a/packages/client-app/internal_packages/composer/stylesheets/composer.less b/packages/client-app/internal_packages/composer/styles/composer.less similarity index 100% rename from packages/client-app/internal_packages/composer/stylesheets/composer.less rename to packages/client-app/internal_packages/composer/styles/composer.less diff --git a/packages/client-app/internal_packages/custom-fonts/stylesheets/fonts.less b/packages/client-app/internal_packages/custom-fonts/styles/fonts.less similarity index 100% rename from packages/client-app/internal_packages/custom-fonts/stylesheets/fonts.less rename to packages/client-app/internal_packages/custom-fonts/styles/fonts.less diff --git a/packages/client-app/internal_packages/draft-list/stylesheets/draft-list.less b/packages/client-app/internal_packages/draft-list/styles/draft-list.less similarity index 100% rename from packages/client-app/internal_packages/draft-list/stylesheets/draft-list.less rename to packages/client-app/internal_packages/draft-list/styles/draft-list.less diff --git a/packages/client-app/internal_packages/events/stylesheets/events.less b/packages/client-app/internal_packages/events/styles/events.less similarity index 100% rename from packages/client-app/internal_packages/events/stylesheets/events.less rename to packages/client-app/internal_packages/events/styles/events.less diff --git a/packages/client-app/internal_packages/github-contact-card/stylesheets/sidebar-github-profile.less b/packages/client-app/internal_packages/github-contact-card/styles/sidebar-github-profile.less similarity index 100% rename from packages/client-app/internal_packages/github-contact-card/stylesheets/sidebar-github-profile.less rename to packages/client-app/internal_packages/github-contact-card/styles/sidebar-github-profile.less diff --git a/packages/client-app/internal_packages/main-calendar/stylesheets/main-calendar.less b/packages/client-app/internal_packages/main-calendar/styles/main-calendar.less similarity index 100% rename from packages/client-app/internal_packages/main-calendar/stylesheets/main-calendar.less rename to packages/client-app/internal_packages/main-calendar/styles/main-calendar.less diff --git a/packages/client-app/internal_packages/message-autoload-images/stylesheets/message-autoload-images.less b/packages/client-app/internal_packages/message-autoload-images/styles/message-autoload-images.less similarity index 100% rename from packages/client-app/internal_packages/message-autoload-images/stylesheets/message-autoload-images.less rename to packages/client-app/internal_packages/message-autoload-images/styles/message-autoload-images.less diff --git a/packages/client-app/internal_packages/message-list/stylesheets/find-in-thread.less b/packages/client-app/internal_packages/message-list/styles/find-in-thread.less similarity index 100% rename from packages/client-app/internal_packages/message-list/stylesheets/find-in-thread.less rename to packages/client-app/internal_packages/message-list/styles/find-in-thread.less diff --git a/packages/client-app/internal_packages/message-list/stylesheets/message-list.less b/packages/client-app/internal_packages/message-list/styles/message-list.less similarity index 100% rename from packages/client-app/internal_packages/message-list/stylesheets/message-list.less rename to packages/client-app/internal_packages/message-list/styles/message-list.less diff --git a/packages/client-app/internal_packages/message-view-on-github/stylesheets/github.less b/packages/client-app/internal_packages/message-view-on-github/styles/github.less similarity index 100% rename from packages/client-app/internal_packages/message-view-on-github/stylesheets/github.less rename to packages/client-app/internal_packages/message-view-on-github/styles/github.less diff --git a/packages/client-app/internal_packages/mode-switch/stylesheets/mode-switch.less b/packages/client-app/internal_packages/mode-switch/styles/mode-switch.less similarity index 100% rename from packages/client-app/internal_packages/mode-switch/stylesheets/mode-switch.less rename to packages/client-app/internal_packages/mode-switch/styles/mode-switch.less diff --git a/packages/client-app/internal_packages/notifications/stylesheets/notifications.less b/packages/client-app/internal_packages/notifications/styles/notifications.less similarity index 100% rename from packages/client-app/internal_packages/notifications/stylesheets/notifications.less rename to packages/client-app/internal_packages/notifications/styles/notifications.less diff --git a/packages/client-app/internal_packages/notifications/stylesheets/styles.less b/packages/client-app/internal_packages/notifications/styles/styles.less similarity index 100% rename from packages/client-app/internal_packages/notifications/stylesheets/styles.less rename to packages/client-app/internal_packages/notifications/styles/styles.less diff --git a/packages/client-app/internal_packages/onboarding/stylesheets/onboarding-reset.less b/packages/client-app/internal_packages/onboarding/styles/onboarding-reset.less similarity index 100% rename from packages/client-app/internal_packages/onboarding/stylesheets/onboarding-reset.less rename to packages/client-app/internal_packages/onboarding/styles/onboarding-reset.less diff --git a/packages/client-app/internal_packages/onboarding/stylesheets/onboarding.less b/packages/client-app/internal_packages/onboarding/styles/onboarding.less similarity index 100% rename from packages/client-app/internal_packages/onboarding/stylesheets/onboarding.less rename to packages/client-app/internal_packages/onboarding/styles/onboarding.less diff --git a/packages/client-app/internal_packages/participant-profile/stylesheets/participant-profile.less b/packages/client-app/internal_packages/participant-profile/styles/participant-profile.less similarity index 100% rename from packages/client-app/internal_packages/participant-profile/stylesheets/participant-profile.less rename to packages/client-app/internal_packages/participant-profile/styles/participant-profile.less diff --git a/packages/client-app/internal_packages/personal-level-indicators/stylesheets/main.less b/packages/client-app/internal_packages/personal-level-indicators/styles/main.less similarity index 100% rename from packages/client-app/internal_packages/personal-level-indicators/stylesheets/main.less rename to packages/client-app/internal_packages/personal-level-indicators/styles/main.less diff --git a/packages/client-app/internal_packages/phishing-detection/stylesheets/index.less b/packages/client-app/internal_packages/phishing-detection/styles/index.less similarity index 100% rename from packages/client-app/internal_packages/phishing-detection/stylesheets/index.less rename to packages/client-app/internal_packages/phishing-detection/styles/index.less diff --git a/packages/client-app/internal_packages/phishing-detection/stylesheets/phishing.less b/packages/client-app/internal_packages/phishing-detection/styles/phishing.less similarity index 100% rename from packages/client-app/internal_packages/phishing-detection/stylesheets/phishing.less rename to packages/client-app/internal_packages/phishing-detection/styles/phishing.less diff --git a/packages/client-app/internal_packages/plugins/stylesheets/plugins.less b/packages/client-app/internal_packages/plugins/styles/plugins.less similarity index 100% rename from packages/client-app/internal_packages/plugins/stylesheets/plugins.less rename to packages/client-app/internal_packages/plugins/styles/plugins.less diff --git a/packages/client-app/internal_packages/preferences/stylesheets/preferences-accounts.less b/packages/client-app/internal_packages/preferences/styles/preferences-accounts.less similarity index 100% rename from packages/client-app/internal_packages/preferences/stylesheets/preferences-accounts.less rename to packages/client-app/internal_packages/preferences/styles/preferences-accounts.less diff --git a/packages/client-app/internal_packages/preferences/stylesheets/preferences-identity.less b/packages/client-app/internal_packages/preferences/styles/preferences-identity.less similarity index 100% rename from packages/client-app/internal_packages/preferences/stylesheets/preferences-identity.less rename to packages/client-app/internal_packages/preferences/styles/preferences-identity.less diff --git a/packages/client-app/internal_packages/preferences/stylesheets/preferences-mail-rules.less b/packages/client-app/internal_packages/preferences/styles/preferences-mail-rules.less similarity index 100% rename from packages/client-app/internal_packages/preferences/stylesheets/preferences-mail-rules.less rename to packages/client-app/internal_packages/preferences/styles/preferences-mail-rules.less diff --git a/packages/client-app/internal_packages/preferences/stylesheets/preferences.less b/packages/client-app/internal_packages/preferences/styles/preferences.less similarity index 100% rename from packages/client-app/internal_packages/preferences/stylesheets/preferences.less rename to packages/client-app/internal_packages/preferences/styles/preferences.less diff --git a/packages/client-app/internal_packages/thread-list/stylesheets/selected-items-stack.less b/packages/client-app/internal_packages/thread-list/styles/selected-items-stack.less similarity index 100% rename from packages/client-app/internal_packages/thread-list/stylesheets/selected-items-stack.less rename to packages/client-app/internal_packages/thread-list/styles/selected-items-stack.less diff --git a/packages/client-app/internal_packages/thread-list/stylesheets/thread-list.less b/packages/client-app/internal_packages/thread-list/styles/thread-list.less similarity index 100% rename from packages/client-app/internal_packages/thread-list/stylesheets/thread-list.less rename to packages/client-app/internal_packages/thread-list/styles/thread-list.less diff --git a/packages/client-app/internal_packages/thread-search/lib/search-query-subscription.es6 b/packages/client-app/internal_packages/thread-search/lib/search-query-subscription.es6 index 4634a94c2..f80ebc467 100644 --- a/packages/client-app/internal_packages/thread-search/lib/search-query-subscription.es6 +++ b/packages/client-app/internal_packages/thread-search/lib/search-query-subscription.es6 @@ -6,14 +6,11 @@ import { DatabaseStore, SearchQueryParser, ComponentRegistry, - NylasLongConnection, FocusedContentStore, MutableQuerySubscription, } from 'nylas-exports' import SearchActions from './search-actions' -const {LongConnectionStatus} = NylasAPI - class SearchQuerySubscription extends MutableQuerySubscription { constructor(searchQuery, accountIds) { @@ -94,37 +91,37 @@ class SearchQuerySubscription extends MutableQuerySubscription { } performRemoteSearch() { - const accountsSearched = new Set() - const allAccountsSearched = () => accountsSearched.size === this._accountIds.length - this._connections = this._accountIds.map((accountId) => { - const conn = new NylasLongConnection({ - accountId, - api: NylasAPI, - path: `/threads/search/streaming?q=${encodeURIComponent(this._searchQuery)}`, - onResults: (results) => { - if (!this._remoteResultsReceivedAt) { - this._remoteResultsReceivedAt = Date.now(); - } - const threads = results[0]; - this._remoteResultsCount += threads.length; - }, - onStatusChanged: (status) => { - const hasClosed = [ - LongConnectionStatus.Closed, - LongConnectionStatus.Ended, - ].includes(status) + // const accountsSearched = new Set() + // const allAccountsSearched = () => accountsSearched.size === this._accountIds.length + // this._connections = this._accountIds.map((accountId) => { + // const conn = new NylasLongConnection({ + // accountId, + // api: NylasAPI, + // path: `/threads/search/streaming?q=${encodeURIComponent(this._searchQuery)}`, + // onResults: (results) => { + // if (!this._remoteResultsReceivedAt) { + // this._remoteResultsReceivedAt = Date.now(); + // } + // const threads = results[0]; + // this._remoteResultsCount += threads.length; + // }, + // onStatusChanged: (status) => { + // const hasClosed = [ + // LongConnectionStatus.Closed, + // LongConnectionStatus.Ended, + // ].includes(status) - if (hasClosed) { - accountsSearched.add(accountId) - if (allAccountsSearched()) { - SearchActions.searchCompleted() - } - } - }, - }) + // if (hasClosed) { + // accountsSearched.add(accountId) + // if (allAccountsSearched()) { + // SearchActions.searchCompleted() + // } + // } + // }, + // }) - return conn.start() - }) + // return conn.start() + // }) } performExtensionSearch() { diff --git a/packages/client-app/internal_packages/thread-search/stylesheets/thread-search-bar.less b/packages/client-app/internal_packages/thread-search/styles/thread-search-bar.less similarity index 100% rename from packages/client-app/internal_packages/thread-search/stylesheets/thread-search-bar.less rename to packages/client-app/internal_packages/thread-search/styles/thread-search-bar.less diff --git a/packages/client-app/internal_packages/thread-snooze/stylesheets/snooze-feature-used-modal.less b/packages/client-app/internal_packages/thread-snooze/styles/snooze-feature-used-modal.less similarity index 100% rename from packages/client-app/internal_packages/thread-snooze/stylesheets/snooze-feature-used-modal.less rename to packages/client-app/internal_packages/thread-snooze/styles/snooze-feature-used-modal.less diff --git a/packages/client-app/internal_packages/thread-snooze/stylesheets/snooze-mail-label.less b/packages/client-app/internal_packages/thread-snooze/styles/snooze-mail-label.less similarity index 100% rename from packages/client-app/internal_packages/thread-snooze/stylesheets/snooze-mail-label.less rename to packages/client-app/internal_packages/thread-snooze/styles/snooze-mail-label.less diff --git a/packages/client-app/internal_packages/thread-snooze/stylesheets/snooze-popover.less b/packages/client-app/internal_packages/thread-snooze/styles/snooze-popover.less similarity index 100% rename from packages/client-app/internal_packages/thread-snooze/stylesheets/snooze-popover.less rename to packages/client-app/internal_packages/thread-snooze/styles/snooze-popover.less diff --git a/packages/client-app/spec/registries/extension-registry-spec.coffee b/packages/client-app/spec/registries/extension-registry-spec.coffee index c2d79b803..36ddd23f5 100644 --- a/packages/client-app/spec/registries/extension-registry-spec.coffee +++ b/packages/client-app/spec/registries/extension-registry-spec.coffee @@ -5,7 +5,6 @@ class TestExtension describe 'ExtensionRegistry', -> beforeEach -> - @originalAdapters = ExtensionRegistry._deprecationAdapters @registry = new ExtensionRegistry.Registry('Test') spyOn @registry, 'triggerDebounced' @@ -43,13 +42,6 @@ describe 'ExtensionRegistry', -> @registry.register({name: 'TestExtension'}) expect(@registry.extensions().length).toEqual 1 - it 'calls deprecationAdapters if present for a role', -> - adapterSpy = jasmine.createSpy('adapterSpy').andCallFake (ext) -> ext - @registry = new ExtensionRegistry.Registry('Test', adapterSpy) - spyOn @registry, 'triggerDebounced' - @registry.register(TestExtension) - expect(adapterSpy.calls.length).toEqual 1 - describe 'unregister', -> it 'unregisters the extension if it exists', -> @registry.register(TestExtension) diff --git a/packages/client-app/src/deprecate-utils.coffee b/packages/client-app/src/deprecate-utils.coffee deleted file mode 100644 index 4c642c40d..000000000 --- a/packages/client-app/src/deprecate-utils.coffee +++ /dev/null @@ -1,30 +0,0 @@ -class DeprecateUtils - # See - # http://www.codeovertones.com/2011/08/how-to-print-stack-trace-anywhere-in.html - @parseStack: (stackString) -> - stack = stackString - .replace(/^[^\(]+?[\n$]/gm, '') - .replace(/^\s+at\s+/gm, '') - .replace(/^Object.\s*\(/gm, '{anonymous}()@') - .split('\n') - return stack - - @warn: (condition, message) -> - console.warn message if condition - - @deprecate: (fnName, newName, ctx, fn) -> - if NylasEnv.inDevMode() and not NylasEnv.inSpecMode() - warn = true - newFn = => - stack = DeprecateUtils.parseStack((new Error()).stack) - DeprecateUtils.warn( - warn, - "Deprecation warning! #{fnName} is deprecated and will be removed soon. - Use #{newName} instead.\nCheck your code at #{stack[1]}" - ) - warn = false - return fn.apply(ctx, arguments) - return Object.assign(newFn, fn) - return fn - -module.exports = DeprecateUtils diff --git a/packages/client-app/src/flux/nylas-api.es6 b/packages/client-app/src/flux/nylas-api.es6 index 41707f520..e03236601 100644 --- a/packages/client-app/src/flux/nylas-api.es6 +++ b/packages/client-app/src/flux/nylas-api.es6 @@ -1,5 +1,4 @@ import AccountStore from './stores/account-store' -import NylasLongConnection from './nylas-long-connection' // A 0 code is when an error returns without a status code, like "ESOCKETTIMEDOUT" const TimeoutErrorCodes = [0, 408, "ETIMEDOUT", "ESOCKETTIMEDOUT", "ECONNRESET", "ENETDOWN", "ENETUNREACH"] @@ -52,7 +51,6 @@ class NylasAPI { this.PermanentErrorCodes = PermanentErrorCodes this.CanceledErrorCodes = CanceledErrorCodes this.SampleTemporaryErrorCode = SampleTemporaryErrorCode - this.LongConnectionStatus = NylasLongConnection.Status } accessTokenForAccountId(aid) { diff --git a/packages/client-app/src/flux/nylas-long-connection.es6 b/packages/client-app/src/flux/nylas-long-connection.es6 deleted file mode 100644 index 255de3e57..000000000 --- a/packages/client-app/src/flux/nylas-long-connection.es6 +++ /dev/null @@ -1,246 +0,0 @@ -/* eslint global-require: 0 */ -import _ from 'underscore' -import url from 'url' -import {Emitter} from 'event-kit' -import {IdentityStore, APIError} from 'nylas-exports' - - -const CONNECTION_TIMEOUT = 60 * 60 * 1000 -const PROCESS_BUFFER_THROTTLE = 400 -const Status = { - None: 'none', - Connecting: 'connecting', - Connected: 'connected', - Closed: 'closed', // Socket has been closed for any reason - Ended: 'ended', // We have received 'end()' and will never open again. -} - -class NylasLongConnection { - static Status = Status - - constructor({api, accountId, ...opts} = {}) { - const { - path, - timeout, - onError, - onResults, - onStatusChanged, - throttleResultsInterval, - closeIfDataStopsInterval, - } = opts - - this._api = api - this._accountId = accountId - this._status = Status.None - this._emitter = new Emitter() - this._req = null - this._buffer = '' - this._results = [] - this._pingTimeout = null - this._httpStatusCode = null - - // Options - this._path = path - this._timeout = timeout || CONNECTION_TIMEOUT - this._onError = onError || (() => {}) - this._onResults = onResults || (() => {}) - this._onStatusChanged = onStatusChanged || (() => {}) - this._closeIfDataStopsInterval = closeIfDataStopsInterval - - this._emitter.on('results-stopped-arriving', this._onResults) - this._processBufferThrottled = _.throttle(this._processBuffer, PROCESS_BUFFER_THROTTLE, {leading: false}) - this._flushResultsSoon = () => { - if (this._results.length === 0) { return } - this._emitter.emit('results-stopped-arriving', this._results); - this._results = [] - } - if (throttleResultsInterval != null) { - this._flushResultsSoon = _.throttle(this._flushResultsSoon, throttleResultsInterval) - } - } - - _processBuffer() { - const bufferJSONs = this._buffer.split('\n') - - // We can't parse the last block - we don't know whether we've - // received the entire result or only part of it. Wait - // until we have more. - this._buffer = bufferJSONs.pop() - - bufferJSONs.forEach((resultJSON) => { - if (resultJSON.length === 0) { return } - let result = null - try { - result = JSON.parse(resultJSON) - } catch (e) { - console.warn(`${resultJSON} could not be parsed as JSON.`, e) - } - if (result) { - this._results.push(result) - } - }) - this._flushResultsSoon() - } - - get accountId() { - return this._accountId; - } - - get status() { - return this._status; - } - - setStatus(status) { - if (this._status === status) { return } - this._status = status - this._onStatusChanged(this._status, this._httpStatusCode) - } - - onError(error) { - this._onError(error) - this.close() - } - - canStart() { - return [Status.None, Status.Closed].includes(this._status) - } - - start() { - if (!this.canStart()) { return this } - if (this._req != null) { return this } - - try { - const accountToken = this._api.accessTokenForAccountId(this._accountId) - const identityToken = (IdentityStore.identity() || {}).token || '' - if (!accountToken) { - throw new APIError({ - statusCode: 401, - message: `Can't establish NylasLongConnection: No account token available for account ${this._accountId}`, - }) - } - - const options = url.parse(`${this._api.APIRoot}${this._path}`) - options.auth = `${accountToken}:${identityToken}` - - let lib; - if (this._api.APIRoot.indexOf('https') === -1) { - lib = require('http') - } else { - lib = require('https') - } - - this._req = lib.request(options, (responseStream) => { - this._req.responseStream = responseStream - this._httpStatusCode = responseStream.statusCode - if (responseStream.statusCode !== 200) { - responseStream.on('data', (chunk) => { - const error = new APIError({ - response: responseStream, - message: chunk.toString('utf8'), - statusCode: responseStream.statusCode, - }) - this.onError(error) - }) - return - } - - responseStream.setEncoding('utf8') - responseStream.on('error', (error) => { - this.onError(new APIError({error})) - }) - responseStream.on('close', () => this.close()) - responseStream.on('end', () => this.close()) - responseStream.on('data', (chunk) => { - this.closeIfDataStops() - // Ignore redundant newlines sent as pings. Want to avoid - // calls to this.onProcessBuffer that contain no actual updates - if (chunk === '\n' && (this._buffer.length === 0 || _.last(this._buffer) === '\n')) { - return - } - this._buffer += chunk - this._processBufferThrottled() - }) - }) - this._req.setTimeout(60 * 60 * 1000) - this._req.setSocketKeepAlive(true) - this._req.on('error', (error) => { - this.onError(new APIError({error})) - }) - this._req.on('socket', (socket) => { - this.setStatus(Status.Connecting) - socket.on('connect', () => { - this.setStatus(Status.Connected) - this.closeIfDataStops() - }) - socket.on('error', (error) => { - this.onError(new APIError({error})) - }) - socket.on('close', () => this.close()) - socket.on('end', () => this.close()) - }) - // We `end` the request to start it. - // See https://github.com/nylas/nylas-mail/pull/2004 - this._req.end() - return this - } catch (err) { - // start() should not throw any errors synchronously. Any errors should be - // asynchronously transmitted to the caller via `onError` - setTimeout(() => this.onError(err), 0) - return this - } - } - - closeIfDataStops() { - if (this._closeIfDataStopsInterval != null) { - clearTimeout(this._pingTimeout) - this._pingTimeout = setTimeout(() => { - this._pingTimeout = null - this.close() - }, this._closeIfDataStopsInterval) - } - } - - dispose(status) { - // Process the buffer one last time before disposing of the connection - // in case there is any data left that we haven't processed - this._processBuffer() - if (this._status !== status) { - this.setStatus(status) - } - clearTimeout(this._pingTimeout) - this._pingTimeout = null - this._httpStatusCode = null - this._buffer = '' - if (this._req) { - this._req.end() - this._req.abort() - this._req.removeAllListeners() - if (this._req.responseStream) { - this._req.responseStream.removeAllListeners() - } - if (this._req.socket) { - this._req.socket.removeAllListeners() - } - - // Keep an error handler to prevent from logging and reporting uncaught - // errors that may occur after aborting this current request. - // For example, if we manually close this connection before any data has - // been received (frequently happens when searching threads), this will - // throw an uncaught socket hang up error that will get unnecessarily - // reported to sentry - this._req.on('error', () => {}) - this._req = null - } - return this - } - - close() { - return this.dispose(Status.Closed) - } - - end() { - return this.dispose(Status.Ended) - } -} - -export default NylasLongConnection diff --git a/packages/client-app/src/flux/stores/message-store.coffee b/packages/client-app/src/flux/stores/message-store.coffee index baea29121..6b229dd8d 100644 --- a/packages/client-app/src/flux/stores/message-store.coffee +++ b/packages/client-app/src/flux/stores/message-store.coffee @@ -9,7 +9,6 @@ FocusedPerspectiveStore = require('./focused-perspective-store').default FocusedContentStore = require "./focused-content-store" NylasAPIHelpers = require '../nylas-api-helpers' ExtensionRegistry = require('../../registries/extension-registry') -{deprecate} = require '../../deprecate-utils' async = require 'async' _ = require 'underscore' @@ -67,24 +66,6 @@ class MessageStore extends NylasStore extensions: => ExtensionRegistry.MessageView.extensions() - # Public: Deprecated, use {ExtensionRegistry.MessageView.register} instead. - # Registers a new extension with the MessageStore. MessageStore extensions - # make it possible to customize message body parsing, and will do more in - # the future. - # - # - `ext` A {MessageViewExtension} instance. - # - registerExtension: (ext) => - ExtensionRegistry.MessageView.register(ext) - - # Public: Deprecated, use {ExtensionRegistry.MessageView.unregister} instead. - # Unregisters the extension provided from the MessageStore. - # - # - `ext` A {MessageViewExtension} instance. - # - unregisterExtension: (ext) => - ExtensionRegistry.MessageView.unregister(ext) - _onExtensionsChanged: (role) -> MessageBodyProcessor = require('./message-body-processor').default MessageBodyProcessor.resetCache() @@ -332,18 +313,6 @@ class MessageStore extends NylasStore store = new MessageStore() -store.registerExtension = deprecate( - 'MessageStore.registerExtension', - 'ExtensionRegistry.MessageView.register', - store, - store.registerExtension -) -store.unregisterExtension = deprecate( - 'MessageStore.unregisterExtension', - 'ExtensionRegistry.MessageView.unregister', - store, - store.unregisterExtension -) store.FolderNamesHiddenByDefault = FolderNamesHiddenByDefault module.exports = store diff --git a/packages/client-app/src/global/nylas-component-kit.coffee b/packages/client-app/src/global/nylas-component-kit.coffee index 3f2505480..bd27e0b3e 100644 --- a/packages/client-app/src/global/nylas-component-kit.coffee +++ b/packages/client-app/src/global/nylas-component-kit.coffee @@ -30,19 +30,11 @@ class NylasComponentKit exported = require "../components/#{path}" return exported[prop] - @loadDeprecated = (prop, path, {instead} = {}) -> - {deprecate} = require '../deprecate-utils' - Object.defineProperty @prototype, prop, - get: deprecate prop, instead, @, -> - exported = NylasComponentKit.default(require "../components/#{path}") - return exported - enumerable: true @load "Menu", 'menu' @load "DropZone", 'drop-zone' @load "Spinner", 'spinner' @load "Switch", 'switch' - @loadDeprecated "Popover", 'popover', instead: 'Actions.openPopover' @load "FixedPopover", 'fixed-popover' @require "DatePickerPopover", 'date-picker-popover' @load "Modal", 'modal' @@ -73,7 +65,6 @@ class NylasComponentKit @load "InjectedComponent", 'injected-component' @load "TokenizingTextField", 'tokenizing-text-field' @load "ParticipantsTextField", 'participants-text-field' - @loadDeprecated "MultiselectActionBar", 'multiselect-action-bar', instead: 'MultiselectToolbar' @load "MultiselectToolbar", 'multiselect-toolbar' @load "InjectedComponentSet", 'injected-component-set' @load "MetadataComposerToggleButton", 'metadata-composer-toggle-button' diff --git a/packages/client-app/src/global/nylas-exports.es6 b/packages/client-app/src/global/nylas-exports.es6 index 75c26b69e..2d24be246 100644 --- a/packages/client-app/src/global/nylas-exports.es6 +++ b/packages/client-app/src/global/nylas-exports.es6 @@ -51,16 +51,6 @@ const lazyLoadAndRegisterTask = (klassName, path) => { DatabaseObjectRegistry.register(klassName, () => exports[klassName]); }; -const lazyLoadDeprecated = (prop, path, {instead} = {}) => { - const {deprecate} = require('../deprecate-utils'); - Object.defineProperty(exports, prop, { - get: deprecate(prop, instead, exports, () => { - return resolveExport(require(`../${path}`)); - }), - enumerable: true, - }); -}; - // Actions lazyLoad(`Actions`, 'flux/actions'); @@ -71,7 +61,6 @@ lazyLoad(`EdgehillAPI`, 'flux/edgehill-api'); lazyLoad(`LegacyEdgehillAPI`, 'flux/legacy-edgehill-api'); lazyLoad(`NylasAPIHelpers`, 'flux/nylas-api-helpers'); lazyLoad(`NylasAPIRequest`, 'flux/nylas-api-request'); -lazyLoad(`NylasLongConnection`, 'flux/nylas-long-connection'); // The Database lazyLoad(`Matcher`, 'flux/attributes/matcher'); @@ -196,7 +185,6 @@ lazyLoad(`FsUtils`, 'fs-utils'); lazyLoad(`CanvasUtils`, 'canvas-utils'); lazyLoad(`RegExpUtils`, 'regexp-utils'); lazyLoad(`MenuHelpers`, 'menu-helpers'); -lazyLoad(`DeprecateUtils`, 'deprecate-utils'); lazyLoad(`VirtualDOMUtils`, 'virtual-dom-utils'); lazyLoad(`Spellchecker`, 'spellchecker'); lazyLoad(`DraftHelpers`, 'flux/stores/draft-helpers'); @@ -231,14 +219,3 @@ lazyLoadWithGetter(`APMWrapper`, () => require('../apm-wrapper')); // Testing lazyLoadWithGetter(`NylasTestUtils`, () => require('../../spec/nylas-test-utils')); - -// Deprecated -lazyLoadDeprecated(`QuotedHTMLParser`, 'services/quoted-html-transformer', { - instead: 'QuotedHTMLTransformer', -}); -lazyLoadDeprecated(`DraftStoreExtension`, 'flux/stores/draft-store-extension', { - instead: 'ComposerExtension', -}); -lazyLoadDeprecated(`MessageStoreExtension`, 'flux/stores/message-store-extension', { - instead: 'MessageViewExtension', -}); diff --git a/packages/client-app/src/registries/extension-registry.es6 b/packages/client-app/src/registries/extension-registry.es6 index 0ca09fad4..b92e7161a 100644 --- a/packages/client-app/src/registries/extension-registry.es6 +++ b/packages/client-app/src/registries/extension-registry.es6 @@ -6,16 +6,14 @@ export class Registry { static include = includeModule; - constructor(name, deprecationAdapter = (ext) => ext) { + constructor(name) { this.name = name; - this._deprecationAdapter = deprecationAdapter; this._registry = new Map(); } - register(ext, {priority = 0} = {}) { - this.validateExtension(ext, 'register'); - const extension = this._deprecationAdapter(ext) - this._registry.set(ext.name, {extension, priority}); + register(extension, {priority = 0} = {}) { + this.validateExtension(extension, 'register'); + this._registry.set(extension.name, {extension, priority}); this.triggerDebounced(); return this; } diff --git a/packages/client-app/src/theme-manager.coffee b/packages/client-app/src/theme-manager.coffee index 22607a93a..613cbda4b 100644 --- a/packages/client-app/src/theme-manager.coffee +++ b/packages/client-app/src/theme-manager.coffee @@ -288,10 +288,6 @@ class ThemeManager themePaths = [] for themeName in @getEnabledThemeNames() if themePath = @packageManager.resolvePackagePath(themeName) - deprecatedPath = path.join(themePath, 'stylesheets') - if fs.isDirectorySync(deprecatedPath) - themePaths.push(deprecatedPath) - else - themePaths.push(path.join(themePath, 'styles')) + themePaths.push(path.join(themePath, 'styles')) themePaths.filter (themePath) -> fs.isDirectorySync(themePath)