diff --git a/src/components/empty-list-state.cjsx b/src/components/empty-list-state.cjsx index 6fa8d0140..a3adc0ddf 100644 --- a/src/components/empty-list-state.cjsx +++ b/src/components/empty-list-state.cjsx @@ -83,15 +83,16 @@ class EmptyListState extends React.Component constructor: (@props) -> @_mounted = false - @state = - syncing: NylasSyncStatusStore.busy() + @state = Object.assign active: false rect: {} + @_getStateFromStores() componentDidMount: -> @_mounted = true @_unlisteners = [] - @_unlisteners.push NylasSyncStatusStore.listen(@_onChange, @) + @_unlisteners.push NylasSyncStatusStore.listen((=> @setState @_getStateFromStores()), @) + @_unlisteners.push FocusedPerspectiveStore.listen((=> @setState @_getStateFromStores()), @) window.addEventListener('resize', @_onResize) if @props.visible and not @state.active rect = @_getDimensions() @@ -149,8 +150,18 @@ class EmptyListState extends React.Component if rect @setState({rect}) - _onChange: -> - @setState - syncing: NylasSyncStatusStore.busy() + _getStateFromStores: -> + currentPerspective = FocusedPerspectiveStore.current() + accountIds = currentPerspective.accountIds + if accountIds.length == 1 + accountId = accountIds[0] + categories = currentPerspective.categories + folderName = null + if categories.length == 1 and categories[0].object == 'folder' + folderName = categories[0].displayName + syncing = !NylasSyncStatusStore.isSyncCompleteForAccount(accountId, folderName) + else + syncing = NylasSyncStatusStore.busy() + return syncing: syncing module.exports = EmptyListState diff --git a/src/flux/stores/nylas-sync-status-store.es6 b/src/flux/stores/nylas-sync-status-store.es6 index c44b6ce15..3ec7253ae 100644 --- a/src/flux/stores/nylas-sync-status-store.es6 +++ b/src/flux/stores/nylas-sync-status-store.es6 @@ -40,7 +40,7 @@ class NylasSyncStatusStore extends NylasStore { constructor() { super() this._statesByAccount = {} - this._subscriptions = new Map() + this._accountSubscriptions = new Map() this._triggerDebounced = _.debounce(this.trigger, 100) this.listenTo(AccountStore, () => this._onAccountsChanged()) @@ -54,28 +54,28 @@ class NylasSyncStatusStore extends NylasStore { }, 30 * 1000) this._onCategoriesChanged() - this._setupSubscriptions(AccountStore.accountIds()) + this._setupAccountSubscriptions(AccountStore.accountIds()) } - _setupSubscriptions(accountIds) { + _setupAccountSubscriptions(accountIds) { accountIds.forEach((accountId) => { - if (this._subscriptions.has(accountId)) { return; } + if (this._accountSubscriptions.has(accountId)) { return; } const query = DatabaseStore.findJSONBlob(`NylasSyncWorker:${accountId}`) const sub = Rx.Observable.fromQuery(query) .subscribe((json) => this._updateState(accountId, json)) - this._subscriptions.set(accountId, sub) + this._accountSubscriptions.set(accountId, sub) }) } _onAccountsChanged() { - const currentIds = Array.from(this.subscriptions.keys()) + const currentIds = Array.from(this._accountSubscriptions.keys()) const nextIds = AccountStore.accountIds() const newIds = _.difference(nextIds, currentIds) const removedIds = _.difference(currentIds, nextIds) removedIds.forEach((accountId) => { - if (this._subscriptions.has(accountId)) { - this._subscriptions.get(accountId).dispose() + if (this._accountSubscriptions.has(accountId)) { + this._accountSubscriptions.get(accountId).dispose() } if (this._statesByAccount[accountId]) { @@ -83,7 +83,7 @@ class NylasSyncStatusStore extends NylasStore { this._triggerDebounced() } }) - this._setupSubscriptions(newIds) + this._setupAccountSubscriptions(newIds) } _onCategoriesChanged() {