From fe924daee38cfd16d34bf68502235639ebfec2ca Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Mon, 7 Aug 2023 10:22:12 -0400 Subject: [PATCH] add option to disable multiselect --- invokeai/frontend/web/src/app/types/invokeai.ts | 3 ++- .../src/features/gallery/hooks/useMultiselect.ts.ts | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/invokeai/frontend/web/src/app/types/invokeai.ts b/invokeai/frontend/web/src/app/types/invokeai.ts index b38790e0c9..827424fa7f 100644 --- a/invokeai/frontend/web/src/app/types/invokeai.ts +++ b/invokeai/frontend/web/src/app/types/invokeai.ts @@ -96,7 +96,8 @@ export type AppFeature = | 'consoleLogging' | 'dynamicPrompting' | 'batches' - | 'syncModels'; + | 'syncModels' + | 'multiselect'; /** * A disable-able Stable Diffusion feature diff --git a/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts.ts b/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts.ts index b59a2f3d6f..a162c6788d 100644 --- a/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts.ts +++ b/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts.ts @@ -9,6 +9,7 @@ import { useListImagesQuery } from 'services/api/endpoints/images'; import { ImageDTO } from 'services/api/types'; import { selectionChanged } from '../store/gallerySlice'; import { imagesSelectors } from 'services/api/util'; +import { useFeatureStatus } from '../../system/hooks/useFeatureStatus'; const selector = createSelector( [stateSelector, selectListImagesBaseQueryArgs], @@ -33,11 +34,18 @@ export const useMultiselect = (imageDTO?: ImageDTO) => { }), }); + const isMultiSelectEnabled = useFeatureStatus('multiselect').isFeatureEnabled; + const handleClick = useCallback( (e: MouseEvent) => { if (!imageDTO) { return; } + if (!isMultiSelectEnabled) { + dispatch(selectionChanged([imageDTO])); + return; + } + if (e.shiftKey) { const rangeEndImageName = imageDTO.image_name; const lastSelectedImage = selection[selection.length - 1]?.image_name; @@ -71,7 +79,7 @@ export const useMultiselect = (imageDTO?: ImageDTO) => { dispatch(selectionChanged([imageDTO])); } }, - [dispatch, imageDTO, imageDTOs, selection] + [dispatch, imageDTO, imageDTOs, selection, isMultiSelectEnabled] ); const isSelected = useMemo(