fix(config): observe fires immediately, causing re-renders

This commit is contained in:
Ben Gotow 2016-01-29 00:31:10 -08:00
parent 140162dcd3
commit 183cbaff17
8 changed files with 12 additions and 12 deletions

View file

@ -45,11 +45,11 @@ class SidebarStore extends NylasStore
@listenTo ThreadCountsStore, @_updateSections
@listenTo CategoryStore, @_updateSections
@configSubscription = NylasEnv.config.observe(
@configSubscription = NylasEnv.config.onDidChange(
'core.workspace.showUnreadForAllCategories',
@_updateSections
)
@configSubscription = NylasEnv.config.observe(
@configSubscription = NylasEnv.config.onDidChange(
'core.accountSidebarCollapsed',
@_updateSections
)

View file

@ -23,7 +23,7 @@ class AutoloadImagesStore extends NylasStore
@listenTo AutoloadImagesActions.temporarilyEnableImages, @_onTemporarilyEnableImages
@listenTo AutoloadImagesActions.permanentlyEnableImages, @_onPermanentlyEnableImages
NylasEnv.config.observe 'core.reading.autoloadImages', =>
NylasEnv.config.onDidChange 'core.reading.autoloadImages', =>
MessageBodyProcessor.resetCache()
shouldBlockImagesIn: (message) =>

View file

@ -8,7 +8,7 @@ class ConfigPropContainer extends React.Component
@state = @getStateFromStores()
componentDidMount: =>
@subscription = NylasEnv.config.observe null, (val) =>
@subscription = NylasEnv.config.onDidChange null, =>
@setState(@getStateFromStores())
componentWillUnmount: =>

View file

@ -45,7 +45,7 @@ class MailImportantIcon extends React.Component
componentDidMount: =>
@unsubscribe = FocusedPerspectiveStore.listen =>
@setState(@getState())
@subscription = NylasEnv.config.observe ShowImportantKey, =>
@subscription = NylasEnv.config.onDidChange ShowImportantKey, =>
@setState(@getState())
componentWillReceiveProps: (nextProps) =>

View file

@ -22,7 +22,7 @@ class CategoryStore extends NylasStore
@_userCategories = {}
@_hiddenCategories = {}
NylasEnv.config.observe 'core.workspace.showImportant', =>
NylasEnv.config.onDidChange 'core.workspace.showImportant', =>
return unless @_categoryResult
@_onCategoriesChanged(@_categoryResult)

View file

@ -11,8 +11,8 @@ class UnreadBadgeStore extends NylasStore
@listenTo FocusedPerspectiveStore, @_updateCount
@listenTo ThreadCountsStore, @_updateCount
NylasEnv.config.observe 'core.notifications.unreadBadge', (val) =>
if val is true
NylasEnv.config.onDidChange 'core.notifications.unreadBadge', ({newValue}) =>
if newValue is true
@_setBadgeForCount()
else
@_setBadge("")

View file

@ -31,9 +31,9 @@ class WorkspaceStore extends NylasStore
@listenTo Actions.focusMailboxPerspective, @popToRootSheet
@_preferredLayoutMode = NylasEnv.config.get('core.workspace.mode')
NylasEnv.config.observe 'core.workspace.mode', (mode) =>
return if mode is @_preferredLayoutMode
@_preferredLayoutMode = mode
NylasEnv.config.onDidChange 'core.workspace.mode', ({newValue}) =>
return if newValue is @_preferredLayoutMode
@_preferredLayoutMode = newValue
@popToRootSheet()
@trigger()

View file

@ -76,7 +76,7 @@ Rx.Observable.fromStore = (store) =>
Rx.Observable.fromConfig = (configKey) =>
return Rx.Observable.create (observer) =>
disposable = NylasEnv.config.observe configKey, =>
disposable = NylasEnv.config.onDidChange configKey, =>
observer.onNext(NylasEnv.config.get(configKey))
observer.onNext(NylasEnv.config.get(configKey))
return Rx.Disposable.create(disposable.dispose)