Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Windows were added
if (!sortedWindows.every(e => leaveKeys.includes(e))) {
// No current layout, so just generate a new one
if (leaveKeys.length < 2) {
return createBalancedTreeFromLeaves(sortedWindows);
}
// Add new windows to layout
const addedWindows = difference(sortedWindows, leaveKeys);
const newLayout = new MosaicLayout(layout);
newLayout.addWindows(addedWindows);
return newLayout.layout;
}
// Windows were removed (perhaps in a different Workspace). We don't have a
// way to reconfigure.. so we have to random generate
if (!leaveKeys.every(e => sortedWindows.includes(e))) {
return createBalancedTreeFromLeaves(sortedWindows);
}
return layout;
}
determineWorkspaceLayout() {
const { windows, layout } = this.props;
const sortedWindows = toPairs(windows)
.sort((a, b) => a.layoutOrder - b.layoutOrder).map(val => val[0]);
const leaveKeys = getLeaves(layout);
// Windows were added
if (!sortedWindows.every(e => leaveKeys.includes(e))) {
// No current layout, so just generate a new one
if (leaveKeys.length < 2) {
return createBalancedTreeFromLeaves(sortedWindows);
}
// Add new windows to layout
const addedWindows = difference(sortedWindows, leaveKeys);
const newLayout = new MosaicLayout(layout);
newLayout.addWindows(addedWindows);
return newLayout.layout;
}
// Windows were removed (perhaps in a different Workspace). We don't have a
// way to reconfigure.. so we have to random generate
if (!leaveKeys.every(e => sortedWindows.includes(e))) {
return createBalancedTreeFromLeaves(sortedWindows);
}
return layout;
}