Skip to content

Commit

Permalink
Adjust binding item component
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamindehli committed May 15, 2024
1 parent 8186d66 commit c571fa4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 44 deletions.
45 changes: 4 additions & 41 deletions src/components/DecentSampler/Binding/BindingItemComponent.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Dependencies
import { Fragment, useContext, useState } from "react";
import { Fragment, useState } from "react";

// Material UI
import MenuItem from "@mui/material/MenuItem";
Expand All @@ -20,28 +20,9 @@ import { DefaultListItem } from "@/components/Template/DefaultListItem";
import { getIndentSize } from "@/functions/helpers";
import { getColorForElementType } from "@/functions/styles";

// Classes
import { ControllableParameter } from "@/classes/ControllableParameter";

// Store
import DecentSamplerContext from "@/store/DecentSamplerContext";

// Data
import controllableParametersData from "@/data/controllableParameters.js";

export function BindingItemComponent({ bindingItem }) {
const theme = useTheme();

const decentSamplerContext = useContext(DecentSamplerContext);
const [controllableParameters, setControllableParameters] = useState(
controllableParametersData.map((controllableParameter) => {
return new ControllableParameter(controllableParameter);
})
);
const [controllableParameterForBinding, setControllableParameterForBinding] = useState(
getControlParameterForBindingItem(bindingItem)
);

const [isExpanded, setIsExpanded] = useState(false);

const [editBindingItemDialogIsOpen, setEditBindingItemDialogIsOpen] = useState(false);
Expand All @@ -54,24 +35,6 @@ export function BindingItemComponent({ bindingItem }) {
setEditBindingItemDialogIsOpen(false);
};

function getControlParameterForBindingItem(binding) {
return controllableParameters.find((controllableParameter) => {
return (
controllableParameter.type === binding.type &&
controllableParameter.level === binding.level &&
controllableParameter.parameter === binding.parameter
);
});
}

/* useEffect(() => {
const controllableParameter = getControlParameterForBindingItem(bindingItem);
setControllableParameterForBinding(controllableParameter);
if (!controllableParameter) {
console.log("noMatch", bindingItem);
}
}, [bindingItem]);*/

const settingsMenuItems = (
<Fragment>
<MenuItem
Expand Down Expand Up @@ -100,7 +63,9 @@ export function BindingItemComponent({ bindingItem }) {
);

const primaryText = "Binding";
const secondaryText = <ListItemSecondaryText>{controllableParameterForBinding?.description}</ListItemSecondaryText>;
const secondaryText = (
<ListItemSecondaryText>{bindingItem?.controllableParameterRef?.description}</ListItemSecondaryText>
);

return (
<Fragment>
Expand All @@ -125,8 +90,6 @@ export function BindingItemComponent({ bindingItem }) {
</DefaultListItem>
<EditBindingItemDialog
bindingItem={bindingItem}
controllableParameters={controllableParameters}
controllableParameterForBinding={controllableParameterForBinding}
open={editBindingItemDialogIsOpen}
onClose={handleCloseEditBindingItemDialog}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import { IconControllableParameter } from "@/components/Template/Icons/IconContr

export function EditBindingItemDialog({
bindingItem,
controllableParameters,
controllableParameterForBinding,
open,
onClose
}) {
Expand Down Expand Up @@ -88,7 +86,6 @@ export function EditBindingItemDialog({

<BindingParameterSelect
onChange={handleBindingParameterChange}
controllableParameters={controllableParameters}
defaultValue={selectedBindingParameter}
/>
{selectedBindingParameter && (
Expand Down

0 comments on commit c571fa4

Please sign in to comment.