mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): fix more state => state
selectors
This commit is contained in:
parent
29bbb27289
commit
823edbfdef
@ -2,7 +2,6 @@ import { Flex } from '@chakra-ui/react';
|
|||||||
import { memo } from 'react';
|
import { memo } from 'react';
|
||||||
|
|
||||||
import CurrentImageButtons from './CurrentImageButtons';
|
import CurrentImageButtons from './CurrentImageButtons';
|
||||||
import CurrentImagePreview from './CurrentImagePreview';
|
|
||||||
|
|
||||||
const CurrentImageDisplay = () => {
|
const CurrentImageDisplay = () => {
|
||||||
return (
|
return (
|
||||||
@ -16,7 +15,7 @@ const CurrentImageDisplay = () => {
|
|||||||
justifyContent="center"
|
justifyContent="center"
|
||||||
>
|
>
|
||||||
<CurrentImageButtons />
|
<CurrentImageButtons />
|
||||||
<CurrentImagePreview />
|
{/* <CurrentImagePreview /> */}
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
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 type { ListImagesArgs } from 'services/api/types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -8,17 +8,15 @@ import {
|
|||||||
INITIAL_IMAGE_LIMIT,
|
INITIAL_IMAGE_LIMIT,
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
export const gallerySelector = (state: RootState) => state.gallery;
|
|
||||||
|
|
||||||
export const selectLastSelectedImage = createMemoizedSelector(
|
export const selectLastSelectedImage = createMemoizedSelector(
|
||||||
(state: RootState) => state,
|
selectGallerySlice,
|
||||||
(s) => s.gallery.selection[state.gallery.selection.length - 1]
|
(gallery) => gallery.selection[gallery.selection.length - 1]
|
||||||
);
|
);
|
||||||
|
|
||||||
export const selectListImagesBaseQueryArgs = createMemoizedSelector(
|
export const selectListImagesBaseQueryArgs = createMemoizedSelector(
|
||||||
[(state: RootState) => state],
|
selectGallerySlice,
|
||||||
(state) => {
|
(gallery) => {
|
||||||
const { selectedBoardId, galleryView } = state.gallery;
|
const { selectedBoardId, galleryView } = gallery;
|
||||||
const categories =
|
const categories =
|
||||||
galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES;
|
galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES;
|
||||||
|
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
import { createMemoizedSelector } from 'app/store/createMemoizedSelector';
|
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 { isString } from 'lodash-es';
|
||||||
|
|
||||||
import { tabMap } from './tabMap';
|
import { tabMap } from './tabMap';
|
||||||
|
|
||||||
export const activeTabNameSelector = createMemoizedSelector(
|
export const activeTabNameSelector = createMemoizedSelector(
|
||||||
(state: RootState) => state,
|
selectUiSlice,
|
||||||
/**
|
/**
|
||||||
* Previously `activeTab` was an integer, but now it's a string.
|
* Previously `activeTab` was an integer, but now it's a string.
|
||||||
* Default to first tab in case user has integer.
|
* 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(
|
export const activeTabIndexSelector = createMemoizedSelector(
|
||||||
(state: RootState) => state,
|
selectUiSlice,
|
||||||
({ ui, config }) => {
|
selectConfigSlice,
|
||||||
|
(ui, config) => {
|
||||||
const tabs = tabMap.filter((t) => !config.disabledTabs.includes(t));
|
const tabs = tabMap.filter((t) => !config.disabledTabs.includes(t));
|
||||||
const idx = tabs.indexOf(ui.activeTab);
|
const idx = tabs.indexOf(ui.activeTab);
|
||||||
return idx === -1 ? 0 : idx;
|
return idx === -1 ? 0 : idx;
|
||||||
|
Loading…
Reference in New Issue
Block a user