summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-07-06 13:18:23 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-07-12 10:09:19 +0200
commitffe0c6e418001f532469ce307edea7b82a663cdd (patch)
treed98f0670439d2e208028e532041635c0d862196a
parent17d77726bffdebd4977ff9d39d5ef60acaf861f1 (diff)
downloadmullvadvpn-ffe0c6e418001f532469ce307edea7b82a663cdd.tar.xz
mullvadvpn-ffe0c6e418001f532469ce307edea7b82a663cdd.zip
Add back Redux action creators in devtools
-rw-r--r--gui/src/renderer/redux/store.ts40
1 files changed, 25 insertions, 15 deletions
diff --git a/gui/src/renderer/redux/store.ts b/gui/src/renderer/redux/store.ts
index d9fb467e1c..3579978425 100644
--- a/gui/src/renderer/redux/store.ts
+++ b/gui/src/renderer/redux/store.ts
@@ -1,16 +1,16 @@
-import { combineReducers, createStore, Dispatch } from 'redux';
+import { combineReducers, compose, createStore, Dispatch } from 'redux';
-import { AccountAction } from './account/actions';
+import accountActions, { AccountAction } from './account/actions';
import accountReducer, { IAccountReduxState } from './account/reducers';
-import { ConnectionAction } from './connection/actions';
+import connectionActions, { ConnectionAction } from './connection/actions';
import connectionReducer, { IConnectionReduxState } from './connection/reducers';
-import { SettingsAction } from './settings/actions';
+import settingsActions, { SettingsAction } from './settings/actions';
import settingsReducer, { ISettingsReduxState } from './settings/reducers';
-import { SupportAction } from './support/actions';
+import supportActions, { SupportAction } from './support/actions';
import supportReducer, { ISupportReduxState } from './support/reducers';
-import { UserInterfaceAction } from './userinterface/actions';
+import userInterfaceActions, { UserInterfaceAction } from './userinterface/actions';
import userInterfaceReducer, { IUserInterfaceReduxState } from './userinterface/reducers';
-import { VersionAction } from './version/actions';
+import versionActions, { VersionAction } from './version/actions';
import versionReducer, { IVersionReduxState } from './version/reducers';
export interface IReduxState {
@@ -32,7 +32,7 @@ export type ReduxAction =
export type ReduxStore = ReturnType<typeof configureStore>;
export type ReduxDispatch = Dispatch<ReduxAction>;
-export default function configureStore(initialState?: IReduxState) {
+export default function configureStore() {
const reducers = {
account: accountReducer,
connection: connectionReducer,
@@ -44,11 +44,21 @@ export default function configureStore(initialState?: IReduxState) {
const rootReducer = combineReducers(reducers);
- if (initialState) {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return createStore(rootReducer, initialState, (window as any).__REDUX_DEVTOOLS_EXTENSION__?.());
- } else {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- return createStore(rootReducer, (window as any).__REDUX_DEVTOOLS_EXTENSION__?.());
- }
+ return createStore(rootReducer, composeEnhancers());
+}
+
+function composeEnhancers(): typeof compose {
+ const actionCreators = {
+ ...accountActions,
+ ...connectionActions,
+ ...settingsActions,
+ ...supportActions,
+ ...versionActions,
+ ...userInterfaceActions,
+ };
+
+ return window.env.development
+ ? // eslint-disable-next-line @typescript-eslint/no-explicit-any
+ (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ actionCreators })()
+ : compose();
}