diff options
Diffstat (limited to 'gui/src/renderer/redux/userinterface')
| -rw-r--r-- | gui/src/renderer/redux/userinterface/actions.ts | 32 | ||||
| -rw-r--r-- | gui/src/renderer/redux/userinterface/reducers.ts | 14 |
2 files changed, 45 insertions, 1 deletions
diff --git a/gui/src/renderer/redux/userinterface/actions.ts b/gui/src/renderer/redux/userinterface/actions.ts index affd11798d..d0d1378a88 100644 --- a/gui/src/renderer/redux/userinterface/actions.ts +++ b/gui/src/renderer/redux/userinterface/actions.ts @@ -24,12 +24,25 @@ export interface ISetWindowFocusedAction { focused: boolean; } +export interface IAddScrollPosition { + type: 'ADD_SCROLL_POSITION'; + path: string; + scrollPosition: [number, number]; +} + +export interface IRemoveScrollPosition { + type: 'REMOVE_SCROLL_POSITION'; + path: string; +} + export type UserInterfaceAction = | IUpdateLocaleAction | IUpdateWindowArrowPositionAction | IUpdateConnectionInfoOpenAction | ISetLocationScopeAction - | ISetWindowFocusedAction; + | ISetWindowFocusedAction + | IAddScrollPosition + | IRemoveScrollPosition; function updateLocale(locale: string): IUpdateLocaleAction { return { @@ -65,10 +78,27 @@ function setWindowFocused(focused: boolean): ISetWindowFocusedAction { }; } +function addScrollPosition(path: string, scrollPosition: [number, number]): IAddScrollPosition { + return { + type: 'ADD_SCROLL_POSITION', + path, + scrollPosition, + }; +} + +function removeScrollPosition(path: string): IRemoveScrollPosition { + return { + type: 'REMOVE_SCROLL_POSITION', + path, + }; +} + export default { updateLocale, updateWindowArrowPosition, toggleConnectionPanel, setLocationScope, setWindowFocused, + addScrollPosition, + removeScrollPosition, }; diff --git a/gui/src/renderer/redux/userinterface/reducers.ts b/gui/src/renderer/redux/userinterface/reducers.ts index 4fef8efbfb..05e091797e 100644 --- a/gui/src/renderer/redux/userinterface/reducers.ts +++ b/gui/src/renderer/redux/userinterface/reducers.ts @@ -11,6 +11,7 @@ export interface IUserInterfaceReduxState { connectionPanelVisible: boolean; locationScope: LocationScope; windowFocused: boolean; + scrollPosition: Record<string, [number, number]>; } const initialState: IUserInterfaceReduxState = { @@ -18,6 +19,7 @@ const initialState: IUserInterfaceReduxState = { connectionPanelVisible: false, locationScope: LocationScope.relay, windowFocused: false, + scrollPosition: {}, }; export default function ( @@ -40,6 +42,18 @@ export default function ( case 'SET_WINDOW_FOCUSED': return { ...state, windowFocused: action.focused }; + case 'ADD_SCROLL_POSITION': + return { + ...state, + scrollPosition: { ...state.scrollPosition, [action.path]: action.scrollPosition }, + }; + + case 'REMOVE_SCROLL_POSITION': { + const scrollPosition = { ...state.scrollPosition }; + delete scrollPosition[action.path]; + return { ...state, scrollPosition }; + } + default: return state; } |
