mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-26 19:47:30 +00:00
Persist focus, and handle bad focus
This commit is contained in:
parent
f8544ed126
commit
3f1861d4f8
2 changed files with 11 additions and 7 deletions
|
|
@ -52,7 +52,7 @@ class App extends React.Component {
|
|||
|
||||
_setFocus() {
|
||||
const binding = this._bindings[this.props.focused];
|
||||
if (binding.node) {
|
||||
if (binding && binding.node) {
|
||||
binding.node.focus();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ interface SerializedWindow {
|
|||
|
||||
export interface WindowsSerializedStateV1 {
|
||||
genWindows: { [windowId: string]: SerializedWindow };
|
||||
focused: string;
|
||||
centerRequested: boolean;
|
||||
positions: WindowPositions;
|
||||
}
|
||||
|
|
@ -185,14 +186,15 @@ const windows = (
|
|||
};
|
||||
case LOAD_SERIALIZED_STATE: {
|
||||
const {
|
||||
genWindows: serializedWindows,
|
||||
positions: serializedPositions,
|
||||
centerRequested: serializedCenterRequested
|
||||
genWindows,
|
||||
positions,
|
||||
centerRequested,
|
||||
focused
|
||||
} = action.serializedState.windows;
|
||||
return {
|
||||
...state,
|
||||
genWindows: objectMap(state.genWindows, (w, windowId) => {
|
||||
const serializedW = serializedWindows[windowId];
|
||||
const serializedW = genWindows[windowId];
|
||||
if (serializedW == null) {
|
||||
return w;
|
||||
}
|
||||
|
|
@ -200,13 +202,14 @@ const windows = (
|
|||
}),
|
||||
// Note: We iterate genWindows here, since the positions object may be empty
|
||||
positions: objectMap(state.genWindows, (position, windowId) => {
|
||||
const serializedPosition = serializedPositions[windowId];
|
||||
const serializedPosition = positions[windowId];
|
||||
if (serializedPosition == null) {
|
||||
return state.positions[windowId];
|
||||
}
|
||||
return serializedPosition;
|
||||
}),
|
||||
centerRequested: serializedCenterRequested
|
||||
centerRequested,
|
||||
focused
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -227,6 +230,7 @@ export function getSerializedState(
|
|||
shade: w.shade || false
|
||||
};
|
||||
}),
|
||||
focused: state.focused,
|
||||
positions: state.positions,
|
||||
centerRequested: state.centerRequested
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue