From 8e63cc0ebfeaf7611e35ef3bbb06f007d359647e Mon Sep 17 00:00:00 2001 From: bridiver Date: Fri, 21 Apr 2017 15:32:17 -0700 Subject: [PATCH] handle circular dependencies in reducers - see #8428 auditors @bsclifton @nejczdovc --- js/stores/appStore.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/js/stores/appStore.js b/js/stores/appStore.js index b7d7af04870..73173734973 100644 --- a/js/stores/appStore.js +++ b/js/stores/appStore.js @@ -345,21 +345,7 @@ function handleChangeSettingAction (settingKey, settingValue) { } } -const reducers = [ - require('../../app/browser/reducers/downloadsReducer'), - require('../../app/browser/reducers/flashReducer'), - // tabs, sites and windows reducers need to stay in that order - // until we have a better way to manage dependencies - require('../../app/browser/reducers/tabsReducer'), - require('../../app/browser/reducers/sitesReducer'), - require('../../app/browser/reducers/windowsReducer'), - require('../../app/browser/reducers/spellCheckReducer'), - require('../../app/browser/reducers/clipboardReducer'), - require('../../app/browser/reducers/passwordManagerReducer'), - require('../../app/browser/reducers/tabMessageBoxReducer'), - require('../../app/browser/reducers/dragDropReducer'), - require('../../app/browser/reducers/extensionsReducer') -] +let reducers = [] const applyReducers = (state, action) => reducers.reduce( (appState, reducer) => { @@ -373,6 +359,21 @@ const handleAppAction = (action) => { const ledger = require('../../app/ledger') if (action.actionType === appConstants.APP_SET_STATE) { + reducers = [ + require('../../app/browser/reducers/downloadsReducer'), + require('../../app/browser/reducers/flashReducer'), + // tabs, sites and windows reducers need to stay in that order + // until we have a better way to manage dependencies + require('../../app/browser/reducers/tabsReducer'), + require('../../app/browser/reducers/sitesReducer'), + require('../../app/browser/reducers/windowsReducer'), + require('../../app/browser/reducers/spellCheckReducer'), + require('../../app/browser/reducers/clipboardReducer'), + require('../../app/browser/reducers/passwordManagerReducer'), + require('../../app/browser/reducers/tabMessageBoxReducer'), + require('../../app/browser/reducers/dragDropReducer'), + require('../../app/browser/reducers/extensionsReducer') + ] initialized = true appState = action.appState }