mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-28 20:40:39 +00:00
Move gen window indexing into App
This commit is contained in:
parent
7b7af6b06e
commit
67e1e1f587
2 changed files with 9 additions and 12 deletions
|
|
@ -19,18 +19,12 @@ const App = ({
|
|||
genWindowsInfo,
|
||||
container,
|
||||
filePickers,
|
||||
genWindows = []
|
||||
genWindowComponents
|
||||
}) => {
|
||||
if (closed) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Index genWindows by id
|
||||
const genWindowComponents = genWindows.reduce(
|
||||
(comps, gen) => ({ ...comps, [gen.id]: gen }),
|
||||
{}
|
||||
);
|
||||
|
||||
const windows = objectMap(genWindowsInfo, (w, id) => {
|
||||
switch (id) {
|
||||
case "main":
|
||||
|
|
@ -45,10 +39,10 @@ const App = ({
|
|||
if (!w.generic) {
|
||||
throw new Error("Tried to render an unknown window:", id);
|
||||
}
|
||||
const { Component, title } = genWindowComponents[id];
|
||||
const Component = genWindowComponents[id];
|
||||
return (
|
||||
w.open && (
|
||||
<GenWindow title={title} windowId={id}>
|
||||
<GenWindow title={w.title} windowId={id}>
|
||||
{({ height, width }) => (
|
||||
<Component
|
||||
analyser={media._analyser}
|
||||
|
|
@ -80,8 +74,6 @@ App.propTypes = {
|
|||
|
||||
const mapStateToProps = state => ({
|
||||
closed: state.display.closed,
|
||||
mainWindow: state.windows.mainWindow,
|
||||
equalizer: state.windows.equalizer,
|
||||
genWindowsInfo: state.windows.genWindows
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -135,13 +135,18 @@ class Winamp {
|
|||
// Wait for the skin to load.
|
||||
await storeHas(this.store, state => !state.display.loading);
|
||||
|
||||
const genWindowComponents = {};
|
||||
this.genWindows.forEach(w => {
|
||||
genWindowComponents[w.id] = w.Component;
|
||||
});
|
||||
|
||||
render(
|
||||
<Provider store={this.store}>
|
||||
<App
|
||||
media={this.media}
|
||||
container={this.options.container}
|
||||
filePickers={this.options.filePickers}
|
||||
genWindows={this.genWindows}
|
||||
genWindowComponents={genWindowComponents}
|
||||
/>
|
||||
</Provider>,
|
||||
node
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue