diff --git a/src/components/WorkspaceMosaic.js b/src/components/WorkspaceMosaic.js index 6794ab3f67bee3343bc46d52d541517a918f82d9..c68e4223cc55d03ad840266ce39c6a35257a3429 100644 --- a/src/components/WorkspaceMosaic.js +++ b/src/components/WorkspaceMosaic.js @@ -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)) diff --git a/src/state/reducers/windows.js b/src/state/reducers/windows.js index b64220af7b67bd1d06e329a1ae84d96dc859cb22..75aaf837aa99f90b1f96ca397d043ebe68683290 100644 --- a/src/state/reducers/windows.js +++ b/src/state/reducers/windows.js @@ -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));