diff --git a/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts b/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts index a162c6788d..d9ba0639ac 100644 --- a/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts +++ b/invokeai/frontend/web/src/features/gallery/hooks/useMultiselect.ts @@ -3,13 +3,12 @@ import { stateSelector } from 'app/store/store'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions'; import { selectListImagesBaseQueryArgs } from 'features/gallery/store/gallerySelectors'; -import { uniq } from 'lodash-es'; import { MouseEvent, useCallback, useMemo } from 'react'; 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'; +import { selectionChanged } from '../store/gallerySlice'; const selector = createSelector( [stateSelector, selectListImagesBaseQueryArgs], @@ -60,7 +59,7 @@ export const useMultiselect = (imageDTO?: ImageDTO) => { const start = Math.min(lastClickedIndex, currentClickedIndex); const end = Math.max(lastClickedIndex, currentClickedIndex); const imagesToSelect = imageDTOs.slice(start, end + 1); - dispatch(selectionChanged(uniq(selection.concat(imagesToSelect)))); + dispatch(selectionChanged(selection.concat(imagesToSelect))); } } else if (e.ctrlKey || e.metaKey) { if ( @@ -73,7 +72,7 @@ export const useMultiselect = (imageDTO?: ImageDTO) => { ) ); } else { - dispatch(selectionChanged(uniq(selection.concat(imageDTO)))); + dispatch(selectionChanged(selection.concat(imageDTO))); } } else { dispatch(selectionChanged([imageDTO])); diff --git a/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts b/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts index c78b22dd78..c9fd3607d3 100644 --- a/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts +++ b/invokeai/frontend/web/src/features/gallery/store/gallerySlice.ts @@ -4,6 +4,7 @@ import { boardsApi } from 'services/api/endpoints/boards'; import { imagesApi } from 'services/api/endpoints/images'; import { ImageDTO } from 'services/api/types'; import { BoardId, GalleryState, GalleryView } from './types'; +import { uniqBy } from 'lodash-es'; export const initialGalleryState: GalleryState = { selection: [], @@ -24,7 +25,7 @@ export const gallerySlice = createSlice({ state.selection = action.payload ? [action.payload] : []; }, selectionChanged: (state, action: PayloadAction) => { - state.selection = action.payload; + state.selection = uniqBy(action.payload, (i) => i.image_name); }, shouldAutoSwitchChanged: (state, action: PayloadAction) => { state.shouldAutoSwitch = action.payload;