From 09d80e4375226c9d8507f7ae2fb5386b356ebaac Mon Sep 17 00:00:00 2001 From: Chris Beer <cabeer@stanford.edu> Date: Thu, 31 Jan 2019 11:49:38 -0800 Subject: [PATCH] Add an action and reducer for changing the thumbnail nav state --- src/state/actions/action-types.js | 1 + src/state/actions/window.js | 10 ++++++++++ src/state/reducers/windows.js | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/src/state/actions/action-types.js b/src/state/actions/action-types.js index fad609fe8..c5e503f91 100644 --- a/src/state/actions/action-types.js +++ b/src/state/actions/action-types.js @@ -12,6 +12,7 @@ const ActionTypes = { RECEIVE_MANIFEST: 'RECEIVE_MANIFEST', RECEIVE_MANIFEST_FAILURE: 'RECEIVE_MANIFEST_FAILURE', SET_CONFIG: 'SET_CONFIG', + SET_WINDOW_THUMBNAIL_POSITION: 'SET_WINDOW_THUMBNAIL_POSITION', TOGGLE_WINDOW_SIDE_BAR: 'TOGGLE_WINDOW_SIDE_BAR', UPDATE_CONFIG: 'UPDATE_CONFIG', REMOVE_MANIFEST: 'REMOVE_MANIFEST', diff --git a/src/state/actions/window.js b/src/state/actions/window.js index 395f1b0d6..605b690b8 100644 --- a/src/state/actions/window.js +++ b/src/state/actions/window.js @@ -50,3 +50,13 @@ export function removeWindow(windowId) { export function toggleWindowSideBar(windowId) { return { type: ActionTypes.TOGGLE_WINDOW_SIDE_BAR, windowId }; } + +/** + * toggleWindowSideBar - action creator + * + * @param {String} windowId + * @memberof ActionCreators + */ +export function setWindowThumbnailPosition(windowId, position) { + return { type: ActionTypes.SET_WINDOW_THUMBNAIL_POSITION, windowId, position }; +} diff --git a/src/state/reducers/windows.js b/src/state/reducers/windows.js index d61f61b5b..8c851f824 100644 --- a/src/state/reducers/windows.js +++ b/src/state/reducers/windows.js @@ -22,6 +22,14 @@ const windowsReducer = (state = {}, action) => { sideBarOpen: !state[action.windowId].sideBarOpen, }, }; + case ActionTypes.SET_WINDOW_THUMBNAIL_POSITION: + return { + ...state, + [action.windowId]: { + ...state[action.windowId], + thumbnailNavigationPosition: action.position, + }, + }; case ActionTypes.NEXT_CANVAS: return setCanvasIndex(state, action.windowId, currentIndex => currentIndex + 1); case ActionTypes.PREVIOUS_CANVAS: -- GitLab