restrainer is back

This commit is contained in:
Tom Odem 2024-05-15 21:53:07 -07:00
parent a6f7940d1c
commit fce4ee6086
2 changed files with 9 additions and 17 deletions

View File

@ -8,6 +8,7 @@ import {
addWidget,
addWidgetToSection,
} from 'src/redux/slices/minimapSlice';
import restrainer from './restrainer';
type ReactToMessageProps = {
// define expected input here and it's type (number, string, etc.)
@ -68,22 +69,13 @@ const reactToMessage = ({
break;
}
} else if (widgetToDeploy) {
//console.log('widget deployed:', widgetToDeploy);
//console.log('widgets that are now deployed: ', widgets);
//if we can actually place the widget
if (restrainer({ widgetToDeploy : widgetToDeploy })) {
// restrainer deems that the widget CAN be deployed
//ADD RESTRAINER HERE TO CHECK IF WE CAN PLACE THE WIDGET
/* if (
!restrainer({
visualComplexity: generateModalityMeasure(),
audioComplexity: generateModalityMeasure(),
})
)
return; */
// dispatch action to add new widget
dispatch(addWidget(widgetToDeploy));
dispatch(addWidgetToSection(sectionID));
// dispatch action to add new widget
dispatch(addWidget(widgetToDeploy));
dispatch(addWidgetToSection(sectionID));
}
}
};

View File

@ -355,7 +355,7 @@ export const minimapSlice = createSlice({
Object.keys(state.widgets).forEach((widgetId) => {
const widget = state.widgets[widgetId];
if (widget.screen === screen) {
widget.elements.forEach((element) => {
Array.from(widget.elements).forEach((element) => {
elements[element.id] = element;
});
}