fix(ui): do not use state => state as an input selector

This is a no-no, whoops!
This commit is contained in:
psychedelicious
2024-01-05 19:44:22 +11:00
parent ce64dbefce
commit a23502f7ff
235 changed files with 1087 additions and 951 deletions

View File

@ -9,7 +9,7 @@ import ParamHrfToggle from './ParamHrfToggle';
export const HrfSettings = memo(() => {
const isHRFFeatureEnabled = useFeatureStatus('hrf').isFeatureEnabled;
const hrfEnabled = useAppSelector((state) => state.hrf.hrfEnabled);
const hrfEnabled = useAppSelector((s) => s.hrf.hrfEnabled);
if (!isHRFFeatureEnabled) {
return null;

View File

@ -18,7 +18,7 @@ const options: InvSelectOption[] = [
const ParamHrfMethodSelect = () => {
const dispatch = useAppDispatch();
const { t } = useTranslation();
const hrfMethod = useAppSelector((state) => state.hrf.hrfMethod);
const hrfMethod = useAppSelector((s) => s.hrf.hrfMethod);
const onChange = useCallback<InvSelectOnChange>(
(v) => {

View File

@ -1,27 +1,31 @@
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
import { stateSelector } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl';
import { InvSlider } from 'common/components/InvSlider/InvSlider';
import { setHrfStrength } from 'features/hrf/store/hrfSlice';
import { selectHrfSlice, setHrfStrength } from 'features/hrf/store/hrfSlice';
import { selectConfigSlice } from 'features/system/store/configSlice';
import { memo, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
const selector = createMemoizedSelector([stateSelector], ({ hrf, config }) => {
const { initial, min, sliderMax, inputMax, fineStep, coarseStep } =
config.sd.hrfStrength;
const { hrfStrength } = hrf;
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,
};
});
return {
hrfStrength,
initial,
min,
sliderMax,
inputMax,
step: coarseStep,
fineStep,
};
}
);
const ParamHrfStrength = () => {
const { hrfStrength, initial, min, sliderMax, step, fineStep } =

View File

@ -1,5 +1,6 @@
import type { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from '@reduxjs/toolkit';
import type { RootState } from 'app/store/store';
import type {
ParameterHRFMethod,
ParameterStrength,
@ -38,3 +39,5 @@ export const hrfSlice = createSlice({
export const { setHrfEnabled, setHrfStrength, setHrfMethod } = hrfSlice.actions;
export default hrfSlice.reducer;
export const selectHrfSlice = (state: RootState) => state.hrf;