mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-01-01 13:14:16 +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 ThreadCountsStore, @_updateSections
|
||||||
@listenTo CategoryStore, @_updateSections
|
@listenTo CategoryStore, @_updateSections
|
||||||
|
|
||||||
@configSubscription = NylasEnv.config.observe(
|
@configSubscription = NylasEnv.config.onDidChange(
|
||||||
'core.workspace.showUnreadForAllCategories',
|
'core.workspace.showUnreadForAllCategories',
|
||||||
@_updateSections
|
@_updateSections
|
||||||
)
|
)
|
||||||
@configSubscription = NylasEnv.config.observe(
|
@configSubscription = NylasEnv.config.onDidChange(
|
||||||
'core.accountSidebarCollapsed',
|
'core.accountSidebarCollapsed',
|
||||||
@_updateSections
|
@_updateSections
|
||||||
)
|
)
|
||||||
|
|
|
@ -23,7 +23,7 @@ class AutoloadImagesStore extends NylasStore
|
||||||
@listenTo AutoloadImagesActions.temporarilyEnableImages, @_onTemporarilyEnableImages
|
@listenTo AutoloadImagesActions.temporarilyEnableImages, @_onTemporarilyEnableImages
|
||||||
@listenTo AutoloadImagesActions.permanentlyEnableImages, @_onPermanentlyEnableImages
|
@listenTo AutoloadImagesActions.permanentlyEnableImages, @_onPermanentlyEnableImages
|
||||||
|
|
||||||
NylasEnv.config.observe 'core.reading.autoloadImages', =>
|
NylasEnv.config.onDidChange 'core.reading.autoloadImages', =>
|
||||||
MessageBodyProcessor.resetCache()
|
MessageBodyProcessor.resetCache()
|
||||||
|
|
||||||
shouldBlockImagesIn: (message) =>
|
shouldBlockImagesIn: (message) =>
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ConfigPropContainer extends React.Component
|
||||||
@state = @getStateFromStores()
|
@state = @getStateFromStores()
|
||||||
|
|
||||||
componentDidMount: =>
|
componentDidMount: =>
|
||||||
@subscription = NylasEnv.config.observe null, (val) =>
|
@subscription = NylasEnv.config.onDidChange null, =>
|
||||||
@setState(@getStateFromStores())
|
@setState(@getStateFromStores())
|
||||||
|
|
||||||
componentWillUnmount: =>
|
componentWillUnmount: =>
|
||||||
|
|
|
@ -45,7 +45,7 @@ class MailImportantIcon extends React.Component
|
||||||
componentDidMount: =>
|
componentDidMount: =>
|
||||||
@unsubscribe = FocusedPerspectiveStore.listen =>
|
@unsubscribe = FocusedPerspectiveStore.listen =>
|
||||||
@setState(@getState())
|
@setState(@getState())
|
||||||
@subscription = NylasEnv.config.observe ShowImportantKey, =>
|
@subscription = NylasEnv.config.onDidChange ShowImportantKey, =>
|
||||||
@setState(@getState())
|
@setState(@getState())
|
||||||
|
|
||||||
componentWillReceiveProps: (nextProps) =>
|
componentWillReceiveProps: (nextProps) =>
|
||||||
|
|
|
@ -22,7 +22,7 @@ class CategoryStore extends NylasStore
|
||||||
@_userCategories = {}
|
@_userCategories = {}
|
||||||
@_hiddenCategories = {}
|
@_hiddenCategories = {}
|
||||||
|
|
||||||
NylasEnv.config.observe 'core.workspace.showImportant', =>
|
NylasEnv.config.onDidChange 'core.workspace.showImportant', =>
|
||||||
return unless @_categoryResult
|
return unless @_categoryResult
|
||||||
@_onCategoriesChanged(@_categoryResult)
|
@_onCategoriesChanged(@_categoryResult)
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,8 @@ class UnreadBadgeStore extends NylasStore
|
||||||
|
|
||||||
@listenTo FocusedPerspectiveStore, @_updateCount
|
@listenTo FocusedPerspectiveStore, @_updateCount
|
||||||
@listenTo ThreadCountsStore, @_updateCount
|
@listenTo ThreadCountsStore, @_updateCount
|
||||||
NylasEnv.config.observe 'core.notifications.unreadBadge', (val) =>
|
NylasEnv.config.onDidChange 'core.notifications.unreadBadge', ({newValue}) =>
|
||||||
if val is true
|
if newValue is true
|
||||||
@_setBadgeForCount()
|
@_setBadgeForCount()
|
||||||
else
|
else
|
||||||
@_setBadge("")
|
@_setBadge("")
|
||||||
|
|
|
@ -31,9 +31,9 @@ class WorkspaceStore extends NylasStore
|
||||||
@listenTo Actions.focusMailboxPerspective, @popToRootSheet
|
@listenTo Actions.focusMailboxPerspective, @popToRootSheet
|
||||||
|
|
||||||
@_preferredLayoutMode = NylasEnv.config.get('core.workspace.mode')
|
@_preferredLayoutMode = NylasEnv.config.get('core.workspace.mode')
|
||||||
NylasEnv.config.observe 'core.workspace.mode', (mode) =>
|
NylasEnv.config.onDidChange 'core.workspace.mode', ({newValue}) =>
|
||||||
return if mode is @_preferredLayoutMode
|
return if newValue is @_preferredLayoutMode
|
||||||
@_preferredLayoutMode = mode
|
@_preferredLayoutMode = newValue
|
||||||
@popToRootSheet()
|
@popToRootSheet()
|
||||||
@trigger()
|
@trigger()
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ Rx.Observable.fromStore = (store) =>
|
||||||
|
|
||||||
Rx.Observable.fromConfig = (configKey) =>
|
Rx.Observable.fromConfig = (configKey) =>
|
||||||
return Rx.Observable.create (observer) =>
|
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))
|
||||||
observer.onNext(NylasEnv.config.get(configKey))
|
observer.onNext(NylasEnv.config.get(configKey))
|
||||||
return Rx.Disposable.create(disposable.dispose)
|
return Rx.Disposable.create(disposable.dispose)
|
||||||
|
|
Loading…
Reference in a new issue