Skip to content

Commit

Permalink
Serialize window position as well
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Oct 1, 2018
1 parent 690f650 commit b71e092
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions js/reducers/windows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface SerializedWindow {

export interface WindowsSerializedStateV1 {
genWindows: { [windowId: string]: SerializedWindow };
positions: WindowPositions;
}

const defaultWindowsState: WindowsState = {
Expand Down Expand Up @@ -176,15 +177,25 @@ const windows = (
positions: { ...state.positions, ...action.positions }
};
case LOAD_SERIALIZED_STATE: {
const serializedWindow = action.serializedState.windows.genWindows;
const {
genWindows: serializedWindows,
positions: serializedPositions
} = action.serializedState.windows;
return {
...state,
genWindows: objectMap(state.genWindows, (w, windowId) => {
const serializedW = serializedWindow[windowId];
const serializedW = serializedWindows[windowId];
if (serializedW == null || w.generic) {
return w;
}
return { ...w, ...serializedW };
}),
positions: objectMap(state.positions, (position, windowId) => {
const serializedPosition = serializedPositions[windowId];
if (serializedPosition == null) {
return position;
}
return serializedPosition;
})
};
}
Expand All @@ -205,7 +216,8 @@ export function getSerializedState(
hidden: w.hidden,
shade: w.shade || false
};
})
}),
positions: state.positions
};
}

Expand Down

0 comments on commit b71e092

Please sign in to comment.