Skip to content

Commit ef1cc19

Browse files
chore(ui): dpdm
1 parent 62b0f71 commit ef1cc19

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

invokeai/frontend/web/src/features/gallery/components/ImageGrid/GallerySelectionCountTag.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Tag, TagCloseButton, TagLabel } from '@invoke-ai/ui-library';
22
import { useAppDispatch, useAppSelector, useAppStore } from 'app/store/storeHooks';
33
import { useIsRegionFocused } from 'common/hooks/focus';
4-
import { useGalleryImageNames } from 'features/gallery/components/NewGallery';
4+
import { useGalleryImageNames } from 'features/gallery/components/use-gallery-image-names';
55
import { selectFirstSelectedImage, selectSelectionCount } from 'features/gallery/store/gallerySelectors';
66
import { selectionChanged } from 'features/gallery/store/gallerySlice';
77
import { useRegisteredHotkeys } from 'features/system/components/HotkeysModal/useHotkeyData';

invokeai/frontend/web/src/features/gallery/components/NewGallery.tsx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { Box, Flex, forwardRef, Grid, GridItem, Skeleton, Spinner, Text } from '@invoke-ai/ui-library';
22
import { createSelector } from '@reduxjs/toolkit';
33
import { logger } from 'app/logging/logger';
4-
import { EMPTY_ARRAY } from 'app/store/constants';
54
import { useAppSelector, useAppStore } from 'app/store/storeHooks';
5+
import type { selectListImageNamesQueryArgs } from 'features/gallery/store/gallerySelectors';
66
import {
77
LIMIT,
88
selectGalleryImageMinimumWidth,
99
selectImageToCompare,
1010
selectLastSelectedImage,
11-
selectListImageNamesQueryArgs,
1211
} from 'features/gallery/store/gallerySelectors';
1312
import { imageToCompareChanged, selectionChanged } from 'features/gallery/store/gallerySlice';
1413
import { useRegisteredHotkeys } from 'features/system/components/HotkeysModal/useHotkeyData';
@@ -24,12 +23,13 @@ import type {
2423
VirtuosoGridHandle,
2524
} from 'react-virtuoso';
2625
import { VirtuosoGrid } from 'react-virtuoso';
27-
import { useGetImageNamesQuery, useListImagesQuery } from 'services/api/endpoints/images';
26+
import { useListImagesQuery } from 'services/api/endpoints/images';
2827
import type { ImageDTO } from 'services/api/types';
2928
import { useDebounce } from 'use-debounce';
3029

3130
import { GalleryImage } from './ImageGrid/GalleryImage';
3231
import { GallerySelectionCountTag } from './ImageGrid/GallerySelectionCountTag';
32+
import { useGalleryImageNames } from './use-gallery-image-names';
3333

3434
const log = logger('gallery');
3535

@@ -396,21 +396,6 @@ const useKeepSelectedImageInView = (
396396
}, [imageName, imageNames, rangeRef, rootRef, virtuosoRef]);
397397
};
398398

399-
const getImageNamesQueryOptions = {
400-
selectFromResult: ({ data, isLoading, isFetching }) => ({
401-
imageNames: data ?? EMPTY_ARRAY,
402-
isLoading,
403-
isFetching,
404-
}),
405-
} satisfies Parameters<typeof useGetImageNamesQuery>[1];
406-
407-
export const useGalleryImageNames = () => {
408-
const _queryArgs = useAppSelector(selectListImageNamesQueryArgs);
409-
const [queryArgs] = useDebounce(_queryArgs, DEBOUNCE_DELAY);
410-
const { imageNames, isLoading, isFetching } = useGetImageNamesQuery(queryArgs, getImageNamesQueryOptions);
411-
return { imageNames, isLoading, isFetching, queryArgs };
412-
};
413-
414399
const useScrollableGallery = (rootRef: RefObject<HTMLDivElement>) => {
415400
const [scroller, scrollerRef] = useState<HTMLElement | null>(null);
416401
const [initialize, osInstance] = useOverlayScrollbars({
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { EMPTY_ARRAY } from 'app/store/constants';
2+
import { useAppSelector } from 'app/store/storeHooks';
3+
import { selectListImageNamesQueryArgs } from 'features/gallery/store/gallerySelectors';
4+
import { useGetImageNamesQuery } from 'services/api/endpoints/images';
5+
import { useDebounce } from 'use-debounce';
6+
7+
const getImageNamesQueryOptions = {
8+
selectFromResult: ({ data, isLoading, isFetching }) => ({
9+
imageNames: data ?? EMPTY_ARRAY,
10+
isLoading,
11+
isFetching,
12+
}),
13+
} satisfies Parameters<typeof useGetImageNamesQuery>[1];
14+
15+
export const useGalleryImageNames = () => {
16+
const _queryArgs = useAppSelector(selectListImageNamesQueryArgs);
17+
const [queryArgs] = useDebounce(_queryArgs, 500);
18+
const { imageNames, isLoading, isFetching } = useGetImageNamesQuery(queryArgs, getImageNamesQueryOptions);
19+
return { imageNames, isLoading, isFetching, queryArgs };
20+
};

0 commit comments

Comments
 (0)