Fix dimmer again

This commit is contained in:
Bill 2021-09-17 02:40:11 -04:00
parent 34ad458f87
commit 7ee1a68987

View File

@ -55,16 +55,8 @@ export const FurnitureDimmerView: FC<{}> = props =>
BatchUpdates(() =>
{
let prevDimmerState = 0;
setDimmerState(prevValue =>
{
setLastDimmerState(prevValue);
return widgetEvent.state;
});
setLastDimmerState(prevDimmerState);
setLastDimmerState(dimmerState);
setDimmerState(widgetEvent.state);
setSelectedPresetId(widgetEvent.presetId);
setEffectId(widgetEvent.effectId);
setSelectedEffectId(widgetEvent.effectId);
@ -73,10 +65,11 @@ export const FurnitureDimmerView: FC<{}> = props =>
setBrightness(widgetEvent.brightness);
setSelectedBrightness(widgetEvent.brightness);
});
return;
}
}
}, []);
}, [ dimmerState ]);
CreateEventDispatcherHook(RoomWidgetUpdateDimmerEvent.PRESETS, eventDispatcher, onNitroEvent);
CreateEventDispatcherHook(RoomWidgetUpdateDimmerEvent.HIDE, eventDispatcher, onNitroEvent);
@ -144,6 +137,8 @@ export const FurnitureDimmerView: FC<{}> = props =>
{
if((dimmerState === 0) && (lastDimmerState === 0)) return;
console.log('ye')
widgetHandler.processWidgetMessage(new RoomWidgetDimmerPreviewMessage(selectedColor, selectedBrightness, (selectedEffectId === 2)));
}, [ widgetHandler, dimmerState, lastDimmerState, selectedColor, selectedBrightness, selectedEffectId ]);