diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-07-12 10:09:43 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-07-12 10:09:43 +0200 |
| commit | 51c3233e7f2f7dbf11f11345b378ff58190b72fc (patch) | |
| tree | d98f0670439d2e208028e532041635c0d862196a /gui/src/renderer | |
| parent | 2f303f7158be3256f94ad437b72ab8628cfceaee (diff) | |
| parent | ffe0c6e418001f532469ce307edea7b82a663cdd (diff) | |
| download | mullvadvpn-51c3233e7f2f7dbf11f11345b378ff58190b72fc.tar.xz mullvadvpn-51c3233e7f2f7dbf11f11345b378ff58190b72fc.zip | |
Merge branch 'update-to-electron-11.4.9'
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/app.tsx | 7 | ||||
| -rw-r--r-- | gui/src/renderer/components/AdvancedSettings.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/components/CustomScrollbars.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/HeaderBar.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/NavigationBarStyles.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/PlatformWindow.tsx | 2 | ||||
| -rw-r--r-- | gui/src/renderer/components/Preferences.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/components/SplitTunnelingSettings.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/context.tsx | 4 | ||||
| -rw-r--r-- | gui/src/renderer/preload.ts | 5 | ||||
| -rw-r--r-- | gui/src/renderer/redux/settings/reducers.ts | 2 | ||||
| -rw-r--r-- | gui/src/renderer/redux/store.ts | 43 |
12 files changed, 38 insertions, 43 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index febcaf8bc8..5b4f4be972 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -208,9 +208,6 @@ export default class AppRenderer { // Request the initial state from the main process const initialState = IpcRendererEventChannel.state.get(); - window.platform = initialState.platform; - window.runningInDevelopment = initialState.runningInDevelopment; - this.setLocale(initialState.locale); loadTranslations( messages, @@ -563,7 +560,7 @@ export default class AppRenderer { let expectedContentHeight = 568; // The app content is 12px taller on macOS to fit the top arrow. - if (window.platform === 'darwin' && !this.guiSettings.unpinnedWindow) { + if (window.env.platform === 'darwin' && !this.guiSettings.unpinnedWindow) { expectedContentHeight += 12; } @@ -676,7 +673,7 @@ export default class AppRenderer { } private async autoConnect() { - if (window.runningInDevelopment) { + if (window.env.development) { log.info('Skip autoconnect in development'); } else if (this.autoConnected) { log.info('Skip autoconnect because it was done before'); diff --git a/gui/src/renderer/components/AdvancedSettings.tsx b/gui/src/renderer/components/AdvancedSettings.tsx index 77c815fe61..62232b6b8c 100644 --- a/gui/src/renderer/components/AdvancedSettings.tsx +++ b/gui/src/renderer/components/AdvancedSettings.tsx @@ -441,11 +441,11 @@ export default class AdvancedSettings extends React.Component<IProps, IState> { </Cell.CellButton> </StyledButtonCellGroup> - {(window.platform === 'linux' || window.platform === 'win32') && ( + {(window.env.platform === 'linux' || window.env.platform === 'win32') && ( <StyledButtonCellGroup> <Cell.CellButton onClick={this.props.onViewSplitTunneling}> <Cell.Label> - {window.platform === 'win32' && <StyledBetaLabel />} + {window.env.platform === 'win32' && <StyledBetaLabel />} {messages.pgettext('advanced-settings-view', 'Split tunneling')} </Cell.Label> <Cell.Icon height={12} width={7} source="icon-chevron" /> diff --git a/gui/src/renderer/components/CustomScrollbars.tsx b/gui/src/renderer/components/CustomScrollbars.tsx index 2b5119839c..3dacd26626 100644 --- a/gui/src/renderer/components/CustomScrollbars.tsx +++ b/gui/src/renderer/components/CustomScrollbars.tsx @@ -47,7 +47,7 @@ interface IScrollbarUpdateContext { export default class CustomScrollbars extends React.Component<IProps, IState> { public static defaultProps: IProps = { // auto-hide on macOS by default - autoHide: window.platform === 'darwin', + autoHide: window.env.platform === 'darwin', trackPadding: { x: 2, y: 2 }, }; diff --git a/gui/src/renderer/components/HeaderBar.tsx b/gui/src/renderer/components/HeaderBar.tsx index f3a69f5af2..0dcd2e7ea9 100644 --- a/gui/src/renderer/components/HeaderBar.tsx +++ b/gui/src/renderer/components/HeaderBar.tsx @@ -31,7 +31,7 @@ interface IHeaderBarContainerProps { const HeaderBarContainer = styled.header({}, (props: IHeaderBarContainerProps) => ({ padding: '12px 16px', - paddingTop: window.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px', + paddingTop: window.env.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px', backgroundColor: headerBarStyleColorMap[props.barStyle ?? HeaderBarStyle.default], })); diff --git a/gui/src/renderer/components/NavigationBarStyles.tsx b/gui/src/renderer/components/NavigationBarStyles.tsx index f8ac87f3e2..52aefe323d 100644 --- a/gui/src/renderer/components/NavigationBarStyles.tsx +++ b/gui/src/renderer/components/NavigationBarStyles.tsx @@ -20,7 +20,7 @@ export const StyledNavigationItems = styled.div({ export const StyledNavigationBar = styled.nav((props: { unpinnedWindow: boolean }) => ({ flex: 0, padding: '12px', - paddingTop: window.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px', + paddingTop: window.env.platform === 'darwin' && !props.unpinnedWindow ? '24px' : '12px', })); export const StyledNavigationBarWrapper = styled.div({ diff --git a/gui/src/renderer/components/PlatformWindow.tsx b/gui/src/renderer/components/PlatformWindow.tsx index 83aa7b3f7f..9b18f5f726 100644 --- a/gui/src/renderer/components/PlatformWindow.tsx +++ b/gui/src/renderer/components/PlatformWindow.tsx @@ -10,7 +10,7 @@ interface IPlatformWindowProps { export default styled.div({}, (props: IPlatformWindowProps) => { let mask: string | undefined; - if (window.platform === 'darwin' && !props.unpinnedWindow) { + if (window.env.platform === 'darwin' && !props.unpinnedWindow) { const arrowPositionCss = props.arrowPosition !== undefined ? `${props.arrowPosition - ARROW_WIDTH * 0.5}px` : '50%'; diff --git a/gui/src/renderer/components/Preferences.tsx b/gui/src/renderer/components/Preferences.tsx index c91330aee0..ebaa2da359 100644 --- a/gui/src/renderer/components/Preferences.tsx +++ b/gui/src/renderer/components/Preferences.tsx @@ -225,8 +225,8 @@ export default class Preferences extends React.Component<IProps> { </Cell.Footer> </AriaInputGroup> - {(window.platform === 'win32' || - (window.platform === 'darwin' && window.runningInDevelopment)) && ( + {(window.env.platform === 'win32' || + (window.env.platform === 'darwin' && window.env.development)) && ( <AriaInputGroup> <Cell.Container> <AriaLabel> diff --git a/gui/src/renderer/components/SplitTunnelingSettings.tsx b/gui/src/renderer/components/SplitTunnelingSettings.tsx index d6f2bbbdcf..30948dae35 100644 --- a/gui/src/renderer/components/SplitTunnelingSettings.tsx +++ b/gui/src/renderer/components/SplitTunnelingSettings.tsx @@ -102,13 +102,13 @@ interface IPlatformSplitTunnelingSettingsProps { } function PlatformSpecificSplitTunnelingSettings(props: IPlatformSplitTunnelingSettingsProps) { - switch (window.platform) { + switch (window.env.platform) { case 'linux': return <LinuxSplitTunnelingSettings {...props} />; case 'win32': return <WindowsSplitTunnelingSettings {...props} />; default: - throw new Error(`Split tunneling not implemented on ${window.platform}`); + throw new Error(`Split tunneling not implemented on ${window.env.platform}`); } } diff --git a/gui/src/renderer/context.tsx b/gui/src/renderer/context.tsx index d4b20daeb1..341ddda893 100644 --- a/gui/src/renderer/context.tsx +++ b/gui/src/renderer/context.tsx @@ -6,7 +6,7 @@ export interface IAppContext { } export const AppContext = React.createContext<IAppContext | undefined>(undefined); -if (window.runningInDevelopment) { +if (window.env.development) { AppContext.displayName = 'AppContext'; } @@ -34,7 +34,7 @@ export default function withAppContext<Props>(BaseComponent: React.ComponentType ); }; - if (window.runningInDevelopment) { + if (window.env.development) { wrappedComponent.displayName = 'withAppContext(' + (BaseComponent.displayName || BaseComponent.name) + ')'; } diff --git a/gui/src/renderer/preload.ts b/gui/src/renderer/preload.ts index 5c44b71eeb..4df178fcc2 100644 --- a/gui/src/renderer/preload.ts +++ b/gui/src/renderer/preload.ts @@ -2,3 +2,8 @@ import { contextBridge } from 'electron'; import { IpcRendererEventChannel } from './lib/ipc-event-channel'; contextBridge.exposeInMainWorld('ipc', IpcRendererEventChannel); + +contextBridge.exposeInMainWorld('env', { + development: process.env.NODE_ENV === 'development', + platform: process.platform, +}); diff --git a/gui/src/renderer/redux/settings/reducers.ts b/gui/src/renderer/redux/settings/reducers.ts index 1b07e805fa..8f61721a6e 100644 --- a/gui/src/renderer/redux/settings/reducers.ts +++ b/gui/src/renderer/redux/settings/reducers.ts @@ -149,7 +149,7 @@ const initialState: ISettingsReduxState = { autoConnect: true, monochromaticIcon: false, startMinimized: false, - unpinnedWindow: window.platform !== 'win32' && window.platform !== 'darwin', + unpinnedWindow: window.env.platform !== 'win32' && window.env.platform !== 'darwin', browsedForSplitTunnelingApplications: [], }, relaySettings: { diff --git a/gui/src/renderer/redux/store.ts b/gui/src/renderer/redux/store.ts index 92d85e4dbe..3579978425 100644 --- a/gui/src/renderer/redux/store.ts +++ b/gui/src/renderer/redux/store.ts @@ -32,16 +32,7 @@ export type ReduxAction = export type ReduxStore = ReturnType<typeof configureStore>; export type ReduxDispatch = Dispatch<ReduxAction>; -export default function configureStore(initialState?: IReduxState) { - const actionCreators = { - ...accountActions, - ...connectionActions, - ...settingsActions, - ...supportActions, - ...versionActions, - ...userInterfaceActions, - }; - +export default function configureStore() { const reducers = { account: accountReducer, connection: connectionReducer, @@ -51,21 +42,23 @@ export default function configureStore(initialState?: IReduxState) { userInterface: userInterfaceReducer, }; - const composeEnhancers: typeof compose = (() => { - // eslint-disable-next-line @typescript-eslint/no-explicit-any - const reduxCompose = window && (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__; - if (window.runningInDevelopment && reduxCompose) { - return reduxCompose({ actionCreators }); - } - return compose; - })(); - - const enhancer = composeEnhancers(); const rootReducer = combineReducers(reducers); - if (initialState) { - return createStore(rootReducer, initialState, enhancer); - } else { - return createStore(rootReducer, enhancer); - } + 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(); } |
