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 {
const { windows, workspace } = this.props;
let windowKeys = Object.keys(windows).sort();
const leaveKeys = getLeaves(workspace.layout);
console.log(Object.keys(windows));
// First, check to see if any windows are maximized
// const maximizedWindows = windowKeys.map(id => windows[id]).filter(window => window.maximized === true)
// if (maximizedWindows.length) {
// windowKeys = maximizedWindows.map(window => window.id);
// }
windowKeys = [windowKeys[0]];
console.log(Object.keys(windows));
// console.log(windowKeys.map(id => windows[id]).filter(window => window.maximized === true));
const maximizedWindows = windowKeys
.map(id => windows[id])
.filter(window => window.maximized === true);
if (maximizedWindows.length) {
windowKeys = maximizedWindows.map(window => window.id);
}
// Check every window is in the layout, and all layout windows are present
// in store
if (!windowKeys.every(e => leaveKeys.includes(e))
......
......@@ -10,23 +10,21 @@ export const windowsReducer = (state = {}, action) => {
return { ...state, [action.window.id]: action.window };
case ActionTypes.MAXIMIZE_WINDOW:
return Object.keys(state).reduce((object, key) => {
if (key === action.windowId) {
object[key] = state[key]; // eslint-disable-line no-param-reassign
object[key].maximized = true; // eslint-disable-line no-param-reassign
}
return object;
}, {});
return {
...state,
[action.windowId]: {
...state[action.windowId],
maximized: true,
},
};
case ActionTypes.MINIMIZE_WINDOW:
return Object.keys(state).reduce((object, key) => {
if (key === action.windowId) {
object[key] = state[key]; // eslint-disable-line no-param-reassign
object[key].maximized = false; // eslint-disable-line no-param-reassign
}
return object;
}, {});
return {
...state,
[action.windowId]: {
...state[action.windowId],
maximized: false,
},
};
case ActionTypes.UPDATE_WINDOW:
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