mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-29 11:52:34 +08:00
fix(config): observe
fires immediately, causing re-renders
This commit is contained in:
parent
140162dcd3
commit
183cbaff17
8 changed files with 12 additions and 12 deletions
|
@ -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
|
||||
)
|
||||
|
|
|
@ -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) =>
|
||||
|
|
|
@ -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: =>
|
||||
|
|
|
@ -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) =>
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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("")
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue