fix(ui): update most other selectors

Just a few stragglers left. Good enough for now.
This commit is contained in:
psychedelicious
2024-01-05 23:35:24 +11:00
parent b71b14d582
commit 3c4150d153
68 changed files with 492 additions and 856 deletions

View File

@ -1,39 +1,21 @@
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl';
import { InvSlider } from 'common/components/InvSlider/InvSlider';
import { selectHrfSlice, setHrfStrength } from 'features/hrf/store/hrfSlice';
import { selectConfigSlice } from 'features/system/store/configSlice';
import { setHrfStrength } from 'features/hrf/store/hrfSlice';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
const selector = createMemoizedSelector(
selectHrfSlice,
selectConfigSlice,
(hrf, config) => {
const { initial, min, sliderMax, inputMax, fineStep, coarseStep } =
config.sd.hrfStrength;
const { hrfStrength } = hrf;
return {
hrfStrength,
initial,
min,
sliderMax,
inputMax,
step: coarseStep,
fineStep,
};
}
);
const ParamHrfStrength = () => {
const { hrfStrength, initial, min, sliderMax, step, fineStep } =
useAppSelector(selector);
const hrfStrength = useAppSelector((s) => s.hrf.hrfStrength);
const initial = useAppSelector((s) => s.config.sd.hrfStrength.initial);
const min = useAppSelector((s) => s.config.sd.hrfStrength.min);
const sliderMax = useAppSelector((s) => s.config.sd.hrfStrength.sliderMax);
const coarseStep = useAppSelector((s) => s.config.sd.hrfStrength.coarseStep);
const fineStep = useAppSelector((s) => s.config.sd.hrfStrength.fineStep);
const dispatch = useAppDispatch();
const { t } = useTranslation();
const handleHrfStrengthChange = useCallback(
const onChange = useCallback(
(v: number) => {
dispatch(setHrfStrength(v));
},
@ -45,11 +27,11 @@ const ParamHrfStrength = () => {
<InvSlider
min={min}
max={sliderMax}
step={step}
step={coarseStep}
fineStep={fineStep}
value={hrfStrength}
defaultValue={initial}
onChange={handleHrfStrengthChange}
onChange={onChange}
marks
withNumberInput
/>