Fix window graph for generic windowsThis allows generic windows to bring along neighbor windows when sizes change (shade mode doubed etc)

This commit is contained in:
Jordan Eldredge 2018-04-26 06:55:00 -07:00
parent 842f12014e
commit 21278239fa
3 changed files with 18 additions and 3 deletions

View file

@ -35,7 +35,7 @@ const App = ({
genWindows.forEach(genWindow => {
const { id, title, Component } = genWindow;
if (genWindowsInfo[id].open) {
windows[`genWindow${id}`] = (
windows[id] = (
<GenWindow key={id} title={title} windowId={id}>
{({ height, width }) => (
<Component

View file

@ -1,5 +1,11 @@
import { createSelector } from "reselect";
import { denormalize, getTimeStr, clamp, percentToIndex } from "./utils";
import {
denormalize,
getTimeStr,
clamp,
percentToIndex,
objectMap
} from "./utils";
import {
BANDS,
TRACK_HEIGHT,
@ -284,7 +290,10 @@ export function getWindowSizes(state) {
playlistShade,
false // The playlist cannot be doubled
);
return { main, equalizer, playlist };
const genWindowSizes = objectMap(state.windows.genWindows, genWindow =>
getWindowPixelSize(genWindow.size)
);
return { main, equalizer, playlist, ...genWindowSizes };
}
export const getWindowGraph = createSelector(

View file

@ -245,3 +245,9 @@ let counter = 0;
export function uniqueId() {
return counter++;
}
export function objectMap(obj, cb) {
const modified = {};
Object.keys(obj).forEach(key => (modified[key] = cb(obj[key])));
return modified;
}