From 823edbfdefcebf08a64f4c1af2bfdaffcf7ed7e5 Mon Sep 17 00:00:00 2001
From: psychedelicious <4822129+psychedelicious@users.noreply.github.com>
Date: Fri, 5 Jan 2024 19:57:25 +1100
Subject: [PATCH] fix(ui): fix more `state => state` selectors
---
.../CurrentImage/CurrentImageDisplay.tsx | 3 +--
.../src/features/gallery/store/gallerySelectors.ts | 14 ++++++--------
.../web/src/features/ui/store/uiSelectors.ts | 12 +++++++-----
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/invokeai/frontend/web/src/features/gallery/components/CurrentImage/CurrentImageDisplay.tsx b/invokeai/frontend/web/src/features/gallery/components/CurrentImage/CurrentImageDisplay.tsx
index 3341131a07..7798f66a9d 100644
--- a/invokeai/frontend/web/src/features/gallery/components/CurrentImage/CurrentImageDisplay.tsx
+++ b/invokeai/frontend/web/src/features/gallery/components/CurrentImage/CurrentImageDisplay.tsx
@@ -2,7 +2,6 @@ import { Flex } from '@chakra-ui/react';
import { memo } from 'react';
import CurrentImageButtons from './CurrentImageButtons';
-import CurrentImagePreview from './CurrentImagePreview';
const CurrentImageDisplay = () => {
return (
@@ -16,7 +15,7 @@ const CurrentImageDisplay = () => {
justifyContent="center"
>
-
+ {/* */}
);
};
diff --git a/invokeai/frontend/web/src/features/gallery/store/gallerySelectors.ts b/invokeai/frontend/web/src/features/gallery/store/gallerySelectors.ts
index 11a682067c..03c84e8096 100644
--- a/invokeai/frontend/web/src/features/gallery/store/gallerySelectors.ts
+++ b/invokeai/frontend/web/src/features/gallery/store/gallerySelectors.ts
@@ -1,5 +1,5 @@
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
-import type { RootState } from 'app/store/store';
+import { selectGallerySlice } from 'features/gallery/store/gallerySlice';
import type { ListImagesArgs } from 'services/api/types';
import {
@@ -8,17 +8,15 @@ import {
INITIAL_IMAGE_LIMIT,
} from './types';
-export const gallerySelector = (state: RootState) => state.gallery;
-
export const selectLastSelectedImage = createMemoizedSelector(
- (state: RootState) => state,
- (s) => s.gallery.selection[state.gallery.selection.length - 1]
+ selectGallerySlice,
+ (gallery) => gallery.selection[gallery.selection.length - 1]
);
export const selectListImagesBaseQueryArgs = createMemoizedSelector(
- [(state: RootState) => state],
- (state) => {
- const { selectedBoardId, galleryView } = state.gallery;
+ selectGallerySlice,
+ (gallery) => {
+ const { selectedBoardId, galleryView } = gallery;
const categories =
galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES;
diff --git a/invokeai/frontend/web/src/features/ui/store/uiSelectors.ts b/invokeai/frontend/web/src/features/ui/store/uiSelectors.ts
index c21bb8591f..5a75325327 100644
--- a/invokeai/frontend/web/src/features/ui/store/uiSelectors.ts
+++ b/invokeai/frontend/web/src/features/ui/store/uiSelectors.ts
@@ -1,21 +1,23 @@
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
-import type { RootState } from 'app/store/store';
+import { selectConfigSlice } from 'features/system/store/configSlice';
+import { selectUiSlice } from 'features/ui/store/uiSlice';
import { isString } from 'lodash-es';
import { tabMap } from './tabMap';
export const activeTabNameSelector = createMemoizedSelector(
- (state: RootState) => state,
+ selectUiSlice,
/**
* Previously `activeTab` was an integer, but now it's a string.
* Default to first tab in case user has integer.
*/
- ({ ui }) => (isString(ui.activeTab) ? ui.activeTab : 'txt2img')
+ (ui) => (isString(ui.activeTab) ? ui.activeTab : 'txt2img')
);
export const activeTabIndexSelector = createMemoizedSelector(
- (state: RootState) => state,
- ({ ui, config }) => {
+ selectUiSlice,
+ selectConfigSlice,
+ (ui, config) => {
const tabs = tabMap.filter((t) => !config.disabledTabs.includes(t));
const idx = tabs.indexOf(ui.activeTab);
return idx === -1 ? 0 : idx;