mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-22 09:37:17 +00:00
Handle the case where positions might be an empty object to begin with
This commit is contained in:
parent
38f032b2c7
commit
f266b60041
2 changed files with 8 additions and 7 deletions
|
|
@ -63,7 +63,7 @@ class WindowManager extends React.Component {
|
|||
y: Math.ceil(offsetTop + (globalOffsetTop + offset))
|
||||
};
|
||||
});
|
||||
this.props.updateWindowPositions(windowPositions);
|
||||
this.props.updateWindowPositions(windowPositions, false);
|
||||
} else {
|
||||
// A layout has been suplied. We will compute the bounding box and
|
||||
// center the given layout.
|
||||
|
|
@ -87,7 +87,7 @@ class WindowManager extends React.Component {
|
|||
{}
|
||||
);
|
||||
|
||||
this.props.updateWindowPositions(newPositions);
|
||||
this.props.updateWindowPositions(newPositions, false);
|
||||
}
|
||||
this.props.windowsHaveBeenCentered();
|
||||
};
|
||||
|
|
@ -171,7 +171,7 @@ class WindowManager extends React.Component {
|
|||
return diff;
|
||||
}, {});
|
||||
|
||||
this.props.updateWindowPositions(windowPositionDiff);
|
||||
this.props.updateWindowPositions(windowPositionDiff, false);
|
||||
};
|
||||
|
||||
const removeListeners = () => {
|
||||
|
|
@ -228,8 +228,8 @@ const mapStateToProps = state => ({
|
|||
|
||||
const mapDispatchToProps = dispatch => {
|
||||
return {
|
||||
updateWindowPositions: positions =>
|
||||
dispatch(updateWindowPositions(positions)),
|
||||
updateWindowPositions: (positions, centered) =>
|
||||
dispatch(updateWindowPositions(positions, centered)),
|
||||
windowsHaveBeenCentered: () => dispatch(windowsHaveBeenCentered())
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -198,10 +198,11 @@ const windows = (
|
|||
}
|
||||
return { ...w, ...serializedW };
|
||||
}),
|
||||
positions: objectMap(state.positions, (position, windowId) => {
|
||||
// Note: We iterate genWindows here, since the positions object may be empty
|
||||
positions: objectMap(state.genWindows, (position, windowId) => {
|
||||
const serializedPosition = serializedPositions[windowId];
|
||||
if (serializedPosition == null) {
|
||||
return position;
|
||||
return state.positions[windowId];
|
||||
}
|
||||
return serializedPosition;
|
||||
}),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue