summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2021-09-09 21:05:58 +0200
committerOskar Nyberg <oskar@mullvad.net>2021-09-10 15:29:51 +0200
commit9a6010657f0983672dd2f36436d5bceb104566bd (patch)
tree26e83bb0bab606c1395424fc0b8e3de6a6cb03ca
parent5814461b5918f63fb834231366eeff5d05bee6bd (diff)
downloadmullvadvpn-9a6010657f0983672dd2f36436d5bceb104566bd.tar.xz
mullvadvpn-9a6010657f0983672dd2f36436d5bceb104566bd.zip
Store macOS scrollbar visibility in redux state
-rw-r--r--gui/src/renderer/app.tsx11
-rw-r--r--gui/src/renderer/redux/userinterface/actions.ts19
-rw-r--r--gui/src/renderer/redux/userinterface/reducers.ts6
3 files changed, 35 insertions, 1 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 851a37a591..781bbd4a14 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -4,6 +4,7 @@ import { Router } from 'react-router';
import { bindActionCreators } from 'redux';
import AppRouter from './components/AppRouter';
+import MacOsScrollbarDetection from './components/MacOsScrollbarDetection';
import ErrorBoundary from './components/ErrorBoundary';
import { AppContext } from './context';
@@ -203,6 +204,10 @@ export default class AppRenderer {
this.reduxActions.userInterface.setWindowFocused(focus);
});
+ IpcRendererEventChannel.window.listenMacOsScrollbarVisibility((visibility) => {
+ this.reduxActions.userInterface.setMacOsScrollbarVisibility(visibility);
+ });
+
IpcRendererEventChannel.navigation.listenReset(() => this.history.dismiss(true));
// Request the initial state from the main process
@@ -237,6 +242,12 @@ export default class AppRenderer {
this.storeAutoStart(initialState.autoStart);
this.setWireguardPublicKey(initialState.wireguardPublicKey);
+ if (initialState.macOsScrollbarVisibility !== undefined) {
+ this.reduxActions.userInterface.setMacOsScrollbarVisibility(
+ initialState.macOsScrollbarVisibility,
+ );
+ }
+
if (initialState.isConnected) {
void this.onDaemonConnected();
}
diff --git a/gui/src/renderer/redux/userinterface/actions.ts b/gui/src/renderer/redux/userinterface/actions.ts
index d0d1378a88..fd08dccd54 100644
--- a/gui/src/renderer/redux/userinterface/actions.ts
+++ b/gui/src/renderer/redux/userinterface/actions.ts
@@ -1,3 +1,4 @@
+import { MacOsScrollbarVisibility } from '../../../shared/ipc-schema';
import { LocationScope } from './reducers';
export interface IUpdateLocaleAction {
@@ -35,6 +36,11 @@ export interface IRemoveScrollPosition {
path: string;
}
+export interface ISetMacOsScrollbarVisibility {
+ type: 'SET_MACOS_SCROLLBAR_VISIBILITY';
+ visibility: MacOsScrollbarVisibility;
+}
+
export type UserInterfaceAction =
| IUpdateLocaleAction
| IUpdateWindowArrowPositionAction
@@ -42,7 +48,8 @@ export type UserInterfaceAction =
| ISetLocationScopeAction
| ISetWindowFocusedAction
| IAddScrollPosition
- | IRemoveScrollPosition;
+ | IRemoveScrollPosition
+ | ISetMacOsScrollbarVisibility;
function updateLocale(locale: string): IUpdateLocaleAction {
return {
@@ -93,6 +100,15 @@ function removeScrollPosition(path: string): IRemoveScrollPosition {
};
}
+function setMacOsScrollbarVisibility(
+ visibility: MacOsScrollbarVisibility,
+): ISetMacOsScrollbarVisibility {
+ return {
+ type: 'SET_MACOS_SCROLLBAR_VISIBILITY',
+ visibility,
+ };
+}
+
export default {
updateLocale,
updateWindowArrowPosition,
@@ -101,4 +117,5 @@ export default {
setWindowFocused,
addScrollPosition,
removeScrollPosition,
+ setMacOsScrollbarVisibility,
};
diff --git a/gui/src/renderer/redux/userinterface/reducers.ts b/gui/src/renderer/redux/userinterface/reducers.ts
index 05e091797e..846007f20a 100644
--- a/gui/src/renderer/redux/userinterface/reducers.ts
+++ b/gui/src/renderer/redux/userinterface/reducers.ts
@@ -1,3 +1,4 @@
+import { MacOsScrollbarVisibility } from '../../../shared/ipc-schema';
import { ReduxAction } from '../store';
export enum LocationScope {
@@ -12,6 +13,7 @@ export interface IUserInterfaceReduxState {
locationScope: LocationScope;
windowFocused: boolean;
scrollPosition: Record<string, [number, number]>;
+ macOsScrollbarVisibility?: MacOsScrollbarVisibility;
}
const initialState: IUserInterfaceReduxState = {
@@ -20,6 +22,7 @@ const initialState: IUserInterfaceReduxState = {
locationScope: LocationScope.relay,
windowFocused: false,
scrollPosition: {},
+ macOsScrollbarVisibility: undefined,
};
export default function (
@@ -54,6 +57,9 @@ export default function (
return { ...state, scrollPosition };
}
+ case 'SET_MACOS_SCROLLBAR_VISIBILITY':
+ return { ...state, macOsScrollbarVisibility: action.visibility };
+
default:
return state;
}