fix(ui): tidy remaining selectors

These were just using overly verbose syntax - like explicitly typing `state: RootState`, which is unnecessary.
This commit is contained in:
psychedelicious
2024-01-05 20:33:10 +11:00
parent f5f378d04b
commit 367de44a8b
43 changed files with 91 additions and 140 deletions

View File

@@ -1,4 +1,3 @@
import type { RootState } 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';
@@ -8,11 +7,9 @@ import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
const ParamClipSkip = () => {
const clipSkip = useAppSelector(
(state: RootState) => state.generation.clipSkip
);
const clipSkip = useAppSelector((s) => s.generation.clipSkip);
const { model } = useAppSelector((state: RootState) => state.generation);
const { model } = useAppSelector((s) => s.generation);
const dispatch = useAppDispatch();
const { t } = useTranslation();

View File

@@ -1,4 +1,3 @@
import type { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl';
import { InvSelect } from 'common/components/InvSelect/InvSelect';
@@ -14,7 +13,7 @@ import { useTranslation } from 'react-i18next';
const ParamCanvasCoherenceMode = () => {
const dispatch = useAppDispatch();
const canvasCoherenceMode = useAppSelector(
(state: RootState) => state.generation.canvasCoherenceMode
(s) => s.generation.canvasCoherenceMode
);
const { t } = useTranslation();

View File

@@ -1,4 +1,3 @@
import type { RootState } 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';
@@ -9,7 +8,7 @@ import { useTranslation } from 'react-i18next';
const ParamCanvasCoherenceSteps = () => {
const dispatch = useAppDispatch();
const canvasCoherenceSteps = useAppSelector(
(state: RootState) => state.generation.canvasCoherenceSteps
(s) => s.generation.canvasCoherenceSteps
);
const { t } = useTranslation();

View File

@@ -1,4 +1,3 @@
import type { RootState } 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';
@@ -9,7 +8,7 @@ import { useTranslation } from 'react-i18next';
const ParamCanvasCoherenceStrength = () => {
const dispatch = useAppDispatch();
const canvasCoherenceStrength = useAppSelector(
(state: RootState) => state.generation.canvasCoherenceStrength
(s) => s.generation.canvasCoherenceStrength
);
const { t } = useTranslation();

View File

@@ -1,4 +1,3 @@
import type { RootState } 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';
@@ -8,9 +7,7 @@ import { useTranslation } from 'react-i18next';
const ParamMaskBlur = () => {
const dispatch = useAppDispatch();
const maskBlur = useAppSelector(
(state: RootState) => state.generation.maskBlur
);
const maskBlur = useAppSelector((s) => s.generation.maskBlur);
const { t } = useTranslation();
const handleChange = useCallback(

View File

@@ -1,4 +1,3 @@
import type { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl';
import { InvSelect } from 'common/components/InvSelect/InvSelect';
@@ -17,9 +16,7 @@ const options: InvSelectOption[] = [
];
const ParamMaskBlurMethod = () => {
const maskBlurMethod = useAppSelector(
(state: RootState) => state.generation.maskBlurMethod
);
const maskBlurMethod = useAppSelector((s) => s.generation.maskBlurMethod);
const dispatch = useAppDispatch();
const { t } = useTranslation();

View File

@@ -16,8 +16,7 @@ import { useTranslation } from 'react-i18next';
export const ParamPositivePrompt = memo(() => {
const dispatch = useAppDispatch();
const prompt = useAppSelector((s) => s.generation.positivePrompt);
const baseModel = useAppSelector((s) => s.generation.model)
?.base_model;
const baseModel = useAppSelector((s) => s.generation.model)?.base_model;
const textareaRef = useRef<HTMLTextAreaElement>(null);
const { t } = useTranslation();

View File

@@ -1,4 +1,3 @@
import type { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl';
import { InvSwitch } from 'common/components/InvSwitch/wrapper';
@@ -12,7 +11,7 @@ export const ParamSeedRandomize = memo(() => {
const { t } = useTranslation();
const shouldRandomizeSeed = useAppSelector(
(state: RootState) => state.generation.shouldRandomizeSeed
(s) => s.generation.shouldRandomizeSeed
);
const handleChangeShouldRandomizeSeed = useCallback(

View File

@@ -1,5 +1,4 @@
import { NUMPY_RAND_MAX, NUMPY_RAND_MIN } from 'app/constants';
import type { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvButton } from 'common/components/InvButton/InvButton';
import randomInt from 'common/util/randomInt';
@@ -11,7 +10,7 @@ import { FaShuffle } from 'react-icons/fa6';
export const ParamSeedShuffle = memo(() => {
const dispatch = useAppDispatch();
const shouldRandomizeSeed = useAppSelector(
(state: RootState) => state.generation.shouldRandomizeSeed
(s) => s.generation.shouldRandomizeSeed
);
const { t } = useTranslation();

View File

@@ -1,4 +1,3 @@
import type { RootState } 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';
@@ -8,10 +7,10 @@ import { useTranslation } from 'react-i18next';
const ParamSymmetryHorizontal = () => {
const horizontalSymmetrySteps = useAppSelector(
(state: RootState) => state.generation.horizontalSymmetrySteps
(s) => s.generation.horizontalSymmetrySteps
);
const steps = useAppSelector((state: RootState) => state.generation.steps);
const steps = useAppSelector((s) => s.generation.steps);
const dispatch = useAppDispatch();

View File

@@ -1,4 +1,3 @@
import type { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import { InvControl } from 'common/components/InvControl/InvControl';
import { InvSwitch } from 'common/components/InvSwitch/wrapper';
@@ -8,7 +7,7 @@ import { memo, useCallback } from 'react';
const ParamSymmetryToggle = () => {
const shouldUseSymmetry = useAppSelector(
(state: RootState) => state.generation.shouldUseSymmetry
(s) => s.generation.shouldUseSymmetry
);
const dispatch = useAppDispatch();

View File

@@ -1,4 +1,3 @@
import type { RootState } 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';
@@ -8,10 +7,10 @@ import { useTranslation } from 'react-i18next';
const ParamSymmetryVertical = () => {
const verticalSymmetrySteps = useAppSelector(
(state: RootState) => state.generation.verticalSymmetrySteps
(s) => s.generation.verticalSymmetrySteps
);
const steps = useAppSelector((state: RootState) => state.generation.steps);
const steps = useAppSelector((s) => s.generation.steps);
const dispatch = useAppDispatch();

View File

@@ -1,4 +1,3 @@
import type { RootState } from 'app/store/store';
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
import type { GroupBase } from 'chakra-react-select';
import { InvControl } from 'common/components/InvControl/InvControl';
@@ -52,7 +51,7 @@ const ParamESRGANModel = () => {
const { t } = useTranslation();
const esrganModelName = useAppSelector(
(state: RootState) => state.postprocessing.esrganModelName
(s) => s.postprocessing.esrganModelName
);
const dispatch = useAppDispatch();