From 7b9680fff4cec79c773937011919ac5b26fd2bbc Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 8 Mar 2017 12:24:59 -0800 Subject: [PATCH] [client-app] :art: Rename NylasSyncStatusStore to FolderSyncProgressStore Summary: see title Test Plan: manual Reviewers: evan, spang, halla Reviewed By: halla Differential Revision: https://phab.nylas.com/D4141 --- .../notifications/lib/sidebar/activity-sidebar.cjsx | 6 +++--- .../lib/sidebar/initial-sync-activity.jsx | 10 +++++----- .../onboarding/lib/onboarding-store.es6 | 4 ++-- .../internal_packages/thread-list/lib/thread-list.cjsx | 4 ++-- .../thread-snooze/lib/snooze-utils.es6 | 4 ++-- .../thread-snooze/spec/snooze-utils-spec.es6 | 4 ++-- ...re-spec.es6 => folder-sync-progress-store-spec.es6} | 6 +++--- .../client-app/src/components/empty-list-state.cjsx | 4 ++-- packages/client-app/src/flux/models/category.es6 | 6 +++--- packages/client-app/src/flux/stores/account-store.es6 | 9 +++------ ...status-store.es6 => folder-sync-progress-store.es6} | 6 +++--- packages/client-app/src/global/nylas-exports.es6 | 2 +- 12 files changed, 31 insertions(+), 34 deletions(-) rename packages/client-app/spec/stores/{nylas-sync-status-store-spec.es6 => folder-sync-progress-store-spec.es6} (92%) rename packages/client-app/src/flux/stores/{nylas-sync-status-store.es6 => folder-sync-progress-store.es6} (96%) diff --git a/packages/client-app/internal_packages/notifications/lib/sidebar/activity-sidebar.cjsx b/packages/client-app/internal_packages/notifications/lib/sidebar/activity-sidebar.cjsx index 9705e894f..9aa8cfaf2 100644 --- a/packages/client-app/internal_packages/notifications/lib/sidebar/activity-sidebar.cjsx +++ b/packages/client-app/internal_packages/notifications/lib/sidebar/activity-sidebar.cjsx @@ -11,7 +11,7 @@ SyncbackActivity = require("./syncback-activity").default Actions, TaskQueue, AccountStore, - NylasSyncStatusStore, + FolderSyncProgressStore, TaskQueueStatusStore PerformSendActionTask, SendDraftTask} = require 'nylas-exports' @@ -36,7 +36,7 @@ class ActivitySidebar extends React.Component componentDidMount: => @_unlisteners = [] @_unlisteners.push TaskQueueStatusStore.listen @_onDataChanged - @_unlisteners.push NylasSyncStatusStore.listen @_onDataChanged + @_unlisteners.push FolderSyncProgressStore.listen @_onDataChanged componentWillUnmount: => unlisten() for unlisten in @_unlisteners @@ -82,6 +82,6 @@ class ActivitySidebar extends React.Component _getStateFromStores: => tasks: TaskQueueStatusStore.queue() - isInitialSyncComplete: NylasSyncStatusStore.isSyncComplete() + isInitialSyncComplete: FolderSyncProgressStore.isSyncComplete() module.exports = ActivitySidebar diff --git a/packages/client-app/internal_packages/notifications/lib/sidebar/initial-sync-activity.jsx b/packages/client-app/internal_packages/notifications/lib/sidebar/initial-sync-activity.jsx index 6144a1b53..92ee7104a 100644 --- a/packages/client-app/internal_packages/notifications/lib/sidebar/initial-sync-activity.jsx +++ b/packages/client-app/internal_packages/notifications/lib/sidebar/initial-sync-activity.jsx @@ -1,6 +1,6 @@ import _ from 'underscore'; import _str from 'underscore.string'; -import {Utils, AccountStore, NylasSyncStatusStore, React} from 'nylas-exports'; +import {Utils, AccountStore, FolderSyncProgressStore, React} from 'nylas-exports'; const MONTH_SHORT_FORMATS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; @@ -11,14 +11,14 @@ export default class InitialSyncActivity extends React.Component { constructor(props) { super(props); this.state = { - syncState: NylasSyncStatusStore.getSyncState(), + syncState: FolderSyncProgressStore.getSyncState(), } this.mounted = false; } componentDidMount() { this.mounted = true; - this.unsub = NylasSyncStatusStore.listen(this.onDataChanged) + this.unsub = FolderSyncProgressStore.listen(this.onDataChanged) } shouldComponentUpdate(nextProps, nextState) { @@ -32,7 +32,7 @@ export default class InitialSyncActivity extends React.Component { } onDataChanged = () => { - const syncState = Utils.deepClone(NylasSyncStatusStore.getSyncState()) + const syncState = Utils.deepClone(FolderSyncProgressStore.getSyncState()) this.setState({syncState}); } @@ -68,7 +68,7 @@ export default class InitialSyncActivity extends React.Component { } render() { - if (!AccountStore.accountsAreSyncing() || NylasSyncStatusStore.isSyncComplete()) { + if (!AccountStore.accountsAreSyncing() || FolderSyncProgressStore.isSyncComplete()) { return false; } diff --git a/packages/client-app/internal_packages/onboarding/lib/onboarding-store.es6 b/packages/client-app/internal_packages/onboarding/lib/onboarding-store.es6 index bb42bf486..de336eb44 100644 --- a/packages/client-app/internal_packages/onboarding/lib/onboarding-store.es6 +++ b/packages/client-app/internal_packages/onboarding/lib/onboarding-store.es6 @@ -1,4 +1,4 @@ -import {AccountStore, Actions, IdentityStore, NylasSyncStatusStore} from 'nylas-exports'; +import {AccountStore, Actions, IdentityStore, FolderSyncProgressStore} from 'nylas-exports'; import {ipcRenderer} from 'electron'; import NylasStore from 'nylas-store'; @@ -174,7 +174,7 @@ class OnboardingStore extends NylasStore { provider: this._accountFromAuth.provider, }); } else { - await NylasSyncStatusStore.whenCategoryListSynced(json.id) + await FolderSyncProgressStore.whenCategoryListSynced(json.id) this._onOnboardingComplete(); } } catch (e) { diff --git a/packages/client-app/internal_packages/thread-list/lib/thread-list.cjsx b/packages/client-app/internal_packages/thread-list/lib/thread-list.cjsx index b5cf78c76..3cd1cceb3 100644 --- a/packages/client-app/internal_packages/thread-list/lib/thread-list.cjsx +++ b/packages/client-app/internal_packages/thread-list/lib/thread-list.cjsx @@ -22,7 +22,7 @@ classnames = require 'classnames' ExtensionRegistry, FocusedContentStore, FocusedPerspectiveStore - NylasSyncStatusStore} = require 'nylas-exports' + FolderSyncProgressStore} = require 'nylas-exports' ThreadListColumns = require './thread-list-columns' ThreadListScrollTooltip = require './thread-list-scroll-tooltip' @@ -46,7 +46,7 @@ class ThreadList extends React.Component componentDidMount: => @_reportAppBootTime() - @unsub = NylasSyncStatusStore.listen(@_onSyncStatusChanged) + @unsub = FolderSyncProgressStore.listen(@_onSyncStatusChanged) window.addEventListener('resize', @_onResize, true) ReactDOM.findDOMNode(@).addEventListener('contextmenu', @_onShowContextMenu) @_onResize() diff --git a/packages/client-app/internal_packages/thread-snooze/lib/snooze-utils.es6 b/packages/client-app/internal_packages/thread-snooze/lib/snooze-utils.es6 index 3ecb451c8..52ee0f5f8 100644 --- a/packages/client-app/internal_packages/thread-snooze/lib/snooze-utils.es6 +++ b/packages/client-app/internal_packages/thread-snooze/lib/snooze-utils.es6 @@ -11,7 +11,7 @@ import { DatabaseStore, SyncbackCategoryTask, TaskQueueStatusStore, - NylasSyncStatusStore, + FolderSyncProgressStore, } from 'nylas-exports'; import {SNOOZE_CATEGORY_NAME} from './snooze-constants' @@ -59,7 +59,7 @@ const SnoozeUtils = { }, getSnoozeCategory(accountId, categoryName = SNOOZE_CATEGORY_NAME) { - return NylasSyncStatusStore.whenCategoryListSynced(accountId) + return FolderSyncProgressStore.whenCategoryListSynced(accountId) .then(() => { const allCategories = CategoryStore.categories(accountId) const category = _.findWhere(allCategories, {displayName: categoryName}) diff --git a/packages/client-app/internal_packages/thread-snooze/spec/snooze-utils-spec.es6 b/packages/client-app/internal_packages/thread-snooze/spec/snooze-utils-spec.es6 index 5eba80f7c..859e1e48a 100644 --- a/packages/client-app/internal_packages/thread-snooze/spec/snooze-utils-spec.es6 +++ b/packages/client-app/internal_packages/thread-snooze/spec/snooze-utils-spec.es6 @@ -7,7 +7,7 @@ import { Category, Thread, CategoryStore, - NylasSyncStatusStore, + FolderSyncProgressStore, } from 'nylas-exports' import SnoozeUtils from '../lib/snooze-utils' @@ -15,7 +15,7 @@ xdescribe('Snooze Utils', function snoozeUtils() { beforeEach(() => { this.name = 'Snoozed Folder' this.accId = 123 - spyOn(NylasSyncStatusStore, 'whenCategoryListSynced').andReturn(Promise.resolve()) + spyOn(FolderSyncProgressStore, 'whenCategoryListSynced').andReturn(Promise.resolve()) }) describe('snoozedUntilMessage', () => { diff --git a/packages/client-app/spec/stores/nylas-sync-status-store-spec.es6 b/packages/client-app/spec/stores/folder-sync-progress-store-spec.es6 similarity index 92% rename from packages/client-app/spec/stores/nylas-sync-status-store-spec.es6 rename to packages/client-app/spec/stores/folder-sync-progress-store-spec.es6 index 20f972268..c7efb84cd 100644 --- a/packages/client-app/spec/stores/nylas-sync-status-store-spec.es6 +++ b/packages/client-app/spec/stores/folder-sync-progress-store-spec.es6 @@ -1,8 +1,8 @@ -import {NylasSyncStatusStore} from 'nylas-exports' +import {FolderSyncProgressStore} from 'nylas-exports' -const store = NylasSyncStatusStore +const store = FolderSyncProgressStore -xdescribe('NylasSyncStatusStore', function nylasSyncStatusStore() { +xdescribe('FolderSyncProgressStore', function nylasSyncStatusStore() { beforeEach(() => { store._statesByAccount = {} }); diff --git a/packages/client-app/src/components/empty-list-state.cjsx b/packages/client-app/src/components/empty-list-state.cjsx index 1167a05a9..cd6fc59e5 100644 --- a/packages/client-app/src/components/empty-list-state.cjsx +++ b/packages/client-app/src/components/empty-list-state.cjsx @@ -4,7 +4,7 @@ ReactDOM = require 'react-dom' classNames = require 'classnames' RetinaImg = require('./retina-img').default EventedIFrame = require './evented-iframe' -{NylasSyncStatusStore, +{FolderSyncProgressStore, FocusedPerspectiveStore} = require 'nylas-exports' {SyncingListState} = require 'nylas-component-kit' @@ -91,7 +91,7 @@ class EmptyListState extends React.Component componentDidMount: -> @_mounted = true @_unlisteners = [] - @_unlisteners.push NylasSyncStatusStore.listen((=> @setState @_getStateFromStores()), @) + @_unlisteners.push FolderSyncProgressStore.listen((=> @setState @_getStateFromStores()), @) @_unlisteners.push FocusedPerspectiveStore.listen((=> @setState @_getStateFromStores()), @) window.addEventListener('resize', @_onResize) if @props.visible and not @state.active diff --git a/packages/client-app/src/flux/models/category.es6 b/packages/client-app/src/flux/models/category.es6 index 2b36be7f9..bf19acb53 100644 --- a/packages/client-app/src/flux/models/category.es6 +++ b/packages/client-app/src/flux/models/category.es6 @@ -1,5 +1,5 @@ /* eslint global-require: 0 */ -import {NylasSyncStatusStore} from 'nylas-exports'; +import {FolderSyncProgressStore} from 'nylas-exports'; import Model from './model'; import Attributes from '../attributes'; let AccountStore = null @@ -181,9 +181,9 @@ export default class Category extends Model { // assigned an object type yet, just return based on the sync status for the // entire account. if (this.object !== 'folder') { - return NylasSyncStatusStore.isSyncCompleteForAccount(this.accountId); + return FolderSyncProgressStore.isSyncCompleteForAccount(this.accountId); } - return NylasSyncStatusStore.isSyncCompleteForAccount( + return FolderSyncProgressStore.isSyncCompleteForAccount( this.accountId, this.name || this.displayName ); diff --git a/packages/client-app/src/flux/stores/account-store.es6 b/packages/client-app/src/flux/stores/account-store.es6 index ffb8316be..15d15f493 100644 --- a/packages/client-app/src/flux/stores/account-store.es6 +++ b/packages/client-app/src/flux/stores/account-store.es6 @@ -43,17 +43,14 @@ class AccountStore extends NylasStore { if (NylasEnv.isMainWindow() && newAccountIds.length > 0) { const newId = newAccountIds[0] - // const NylasSyncStatusStore = require('./nylas-sync-status-store').default + Actions.focusDefaultMailboxPerspectiveForAccounts([newId], {sidebarAccountIds: accountIds}) + const FolderSyncProgressStore = require('./folder-sync-progress-store').default + await FolderSyncProgressStore.whenCategoryListSynced(newId) Actions.focusDefaultMailboxPerspectiveForAccounts([newId], {sidebarAccountIds: accountIds}) // TODO: - // Wait for a little bit before uncollapsong the sidebar to show the - // newly focused inbox // This Action is a hack, get rid of it in sidebar refactor // Wait until the FocusedPerspectiveStore triggers and the sidebar is // updated to uncollapse the inbox for the new account - const NylasSyncStatusStore = require('./nylas-sync-status-store').default - await NylasSyncStatusStore.whenCategoryListSynced(newId) - Actions.focusDefaultMailboxPerspectiveForAccounts([newId], {sidebarAccountIds: accountIds}) Actions.setCollapsedSidebarItem('Inbox', false) } }) diff --git a/packages/client-app/src/flux/stores/nylas-sync-status-store.es6 b/packages/client-app/src/flux/stores/folder-sync-progress-store.es6 similarity index 96% rename from packages/client-app/src/flux/stores/nylas-sync-status-store.es6 rename to packages/client-app/src/flux/stores/folder-sync-progress-store.es6 index e56f42d45..a7d6f47aa 100644 --- a/packages/client-app/src/flux/stores/nylas-sync-status-store.es6 +++ b/packages/client-app/src/flux/stores/folder-sync-progress-store.es6 @@ -5,7 +5,7 @@ import CategoryStore from './category-store' /** - * NylasSyncStatusStore keeps track of the sync state per account, and will + * FolderSyncProgressStore keeps track of the sync state per account, and will * trigger whenever it changes. * * The sync state for any given account has the following shape: @@ -25,7 +25,7 @@ import CategoryStore from './category-store' * } * */ -class NylasSyncStatusStore extends NylasStore { +class FolderSyncProgressStore extends NylasStore { constructor() { super() @@ -160,4 +160,4 @@ class NylasSyncStatusStore extends NylasStore { } } -export default new NylasSyncStatusStore() +export default new FolderSyncProgressStore() diff --git a/packages/client-app/src/global/nylas-exports.es6 b/packages/client-app/src/global/nylas-exports.es6 index ead342350..41f942140 100644 --- a/packages/client-app/src/global/nylas-exports.es6 +++ b/packages/client-app/src/global/nylas-exports.es6 @@ -165,7 +165,7 @@ lazyLoadAndRegisterStore(`FocusedContentStore`, 'focused-content-store'); lazyLoadAndRegisterStore(`MessageBodyProcessor`, 'message-body-processor'); lazyLoadAndRegisterStore(`FocusedContactsStore`, 'focused-contacts-store'); lazyLoadAndRegisterStore(`TaskQueueStatusStore`, 'task-queue-status-store'); -lazyLoadAndRegisterStore(`NylasSyncStatusStore`, 'nylas-sync-status-store'); +lazyLoadAndRegisterStore(`FolderSyncProgressStore`, 'folder-sync-progress-store'); lazyLoadAndRegisterStore(`ThreadListActionsStore`, 'thread-list-actions-store'); lazyLoadAndRegisterStore(`FocusedPerspectiveStore`, 'focused-perspective-store'); lazyLoadAndRegisterStore(`SearchableComponentStore`, 'searchable-component-store');