Skip to content
Snippets Groups Projects
Commit de16d782 authored by Jessie Keck's avatar Jessie Keck
Browse files

Update MAXIMIZE/MINIMIZE_WINDOW reducers to not overwrite windows

parent 6e1c2586
No related branches found
No related tags found
No related merge requests found
...@@ -49,15 +49,14 @@ export class WorkspaceMosaic extends React.Component { ...@@ -49,15 +49,14 @@ export class WorkspaceMosaic extends React.Component {
const { windows, workspace } = this.props; const { windows, workspace } = this.props;
let windowKeys = Object.keys(windows).sort(); let windowKeys = Object.keys(windows).sort();
const leaveKeys = getLeaves(workspace.layout); const leaveKeys = getLeaves(workspace.layout);
console.log(Object.keys(windows));
// First, check to see if any windows are maximized // First, check to see if any windows are maximized
// const maximizedWindows = windowKeys.map(id => windows[id]).filter(window => window.maximized === true) const maximizedWindows = windowKeys
// if (maximizedWindows.length) { .map(id => windows[id])
// windowKeys = maximizedWindows.map(window => window.id); .filter(window => window.maximized === true);
// }
windowKeys = [windowKeys[0]]; if (maximizedWindows.length) {
console.log(Object.keys(windows)); windowKeys = maximizedWindows.map(window => window.id);
// console.log(windowKeys.map(id => windows[id]).filter(window => window.maximized === true)); }
// Check every window is in the layout, and all layout windows are present // Check every window is in the layout, and all layout windows are present
// in store // in store
if (!windowKeys.every(e => leaveKeys.includes(e)) if (!windowKeys.every(e => leaveKeys.includes(e))
......
...@@ -10,23 +10,21 @@ export const windowsReducer = (state = {}, action) => { ...@@ -10,23 +10,21 @@ export const windowsReducer = (state = {}, action) => {
return { ...state, [action.window.id]: action.window }; return { ...state, [action.window.id]: action.window };
case ActionTypes.MAXIMIZE_WINDOW: case ActionTypes.MAXIMIZE_WINDOW:
return Object.keys(state).reduce((object, key) => { return {
if (key === action.windowId) { ...state,
object[key] = state[key]; // eslint-disable-line no-param-reassign [action.windowId]: {
object[key].maximized = true; // eslint-disable-line no-param-reassign ...state[action.windowId],
} maximized: true,
return object; },
}, {}); };
case ActionTypes.MINIMIZE_WINDOW: case ActionTypes.MINIMIZE_WINDOW:
return Object.keys(state).reduce((object, key) => { return {
if (key === action.windowId) { ...state,
object[key] = state[key]; // eslint-disable-line no-param-reassign [action.windowId]: {
object[key].maximized = false; // eslint-disable-line no-param-reassign ...state[action.windowId],
} maximized: false,
return object; },
}, {}); };
case ActionTypes.UPDATE_WINDOW: case ActionTypes.UPDATE_WINDOW:
return updateIn(state, [action.id], orig => merge(orig, action.payload)); return updateIn(state, [action.id], orig => merge(orig, action.payload));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment