Files
InvokeAI/invokeai/frontend/web/src/features/queue/components/QueueIterationsNumberInput.tsx
psychedelicious 89ff9b8b88 perf(ui): optimize all selectors 2
Mostly selector optimization. Still a few places to tidy up but I'll get to that later.
2024-09-06 22:56:24 +10:00

42 lines
1.3 KiB
TypeScript

import { CompositeNumberInput } from '@invoke-ai/ui-library';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InformationalPopover } from 'common/components/InformationalPopover/InformationalPopover';
import { selectIterations, setIterations } from 'features/controlLayers/store/paramsSlice';
import { selectIterationsConfig } from 'features/system/store/configSlice';
import { memo, useCallback } from 'react';
export const QueueIterationsNumberInput = memo(() => {
const iterations = useAppSelector(selectIterations);
const config = useAppSelector(selectIterationsConfig);
const dispatch = useAppDispatch();
const handleChange = useCallback(
(v: number) => {
dispatch(setIterations(v));
},
[dispatch]
);
return (
<InformationalPopover feature="paramIterations">
<CompositeNumberInput
step={config.coarseStep}
fineStep={config.fineStep}
min={1}
max={999}
onChange={handleChange}
value={iterations}
defaultValue={1}
pos="absolute"
insetInlineEnd={0}
h="full"
ps={0}
w="72px"
flexShrink={0}
variant="iterations"
/>
</InformationalPopover>
);
});
QueueIterationsNumberInput.displayName = 'QueueIterationsNumberInput';