Avoid import-time side effects for application
Summary: `INITIAL_STATE` is defined at import-time and relies on `remote.getCurrentWindow()`, which means that any import from the `flipper` module will require a display server + electron running. Happy to take alternative suggestions to make this look a bit less intrusive. Reviewed By: danielbuechele Differential Revision: D10507539 fbshipit-source-id: 62b6bff0b4fd40638e54328613de4d3821b69dd6
This commit is contained in:
committed by
Facebook Github Bot
parent
1be54ebee1
commit
2f307b8b4f
@@ -29,19 +29,17 @@ export type Action = {
|
|||||||
payload?: boolean,
|
payload?: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
const INITIAL_STATE: State = {
|
const initialState: () => State = () => ({
|
||||||
leftSidebarVisible: true,
|
leftSidebarVisible: true,
|
||||||
rightSidebarVisible: true,
|
rightSidebarVisible: true,
|
||||||
rightSidebarAvailable: false,
|
rightSidebarAvailable: false,
|
||||||
bugDialogVisible: false,
|
bugDialogVisible: false,
|
||||||
windowIsFocused: remote.getCurrentWindow().isFocused(),
|
windowIsFocused: remote.getCurrentWindow().isFocused(),
|
||||||
pluginManagerVisible: false,
|
pluginManagerVisible: false,
|
||||||
};
|
});
|
||||||
|
|
||||||
export default function reducer(
|
export default function reducer(state: State, action: Action): State {
|
||||||
state: State = INITIAL_STATE,
|
state = state || initialState();
|
||||||
action: Action,
|
|
||||||
): State {
|
|
||||||
const {payload, type} = action;
|
const {payload, type} = action;
|
||||||
const newValue = typeof payload === 'undefined' ? !state[type] : payload;
|
const newValue = typeof payload === 'undefined' ? !state[type] : payload;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user