fix(ui): fix more state => state selectors

This commit is contained in:
psychedelicious 2024-01-05 19:57:25 +11:00
parent 29bbb27289
commit 823edbfdef
3 changed files with 14 additions and 15 deletions

View File

@ -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"
>
<CurrentImageButtons />
<CurrentImagePreview />
{/* <CurrentImagePreview /> */}
</Flex>
);
};

View File

@ -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;

View File

@ -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;