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