mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): deleting image selects first image
This commit is contained in:
parent
6ce867feb4
commit
9ebab013c1
@ -1,21 +1,21 @@
|
|||||||
import { startAppListening } from '..';
|
|
||||||
import { imageDeleted } from 'services/api/thunks/image';
|
|
||||||
import { log } from 'app/logging/useLogger';
|
import { log } from 'app/logging/useLogger';
|
||||||
import { clamp } from 'lodash-es';
|
|
||||||
import {
|
|
||||||
imageSelected,
|
|
||||||
imageRemoved,
|
|
||||||
selectImagesIds,
|
|
||||||
} from 'features/gallery/store/gallerySlice';
|
|
||||||
import { resetCanvas } from 'features/canvas/store/canvasSlice';
|
import { resetCanvas } from 'features/canvas/store/canvasSlice';
|
||||||
import { controlNetReset } from 'features/controlNet/store/controlNetSlice';
|
import { controlNetReset } from 'features/controlNet/store/controlNetSlice';
|
||||||
import { clearInitialImage } from 'features/parameters/store/generationSlice';
|
import {
|
||||||
import { nodeEditorReset } from 'features/nodes/store/nodesSlice';
|
imageRemoved,
|
||||||
import { api } from 'services/api';
|
imageSelected,
|
||||||
|
selectFilteredImages,
|
||||||
|
} from 'features/gallery/store/gallerySlice';
|
||||||
import {
|
import {
|
||||||
imageDeletionConfirmed,
|
imageDeletionConfirmed,
|
||||||
isModalOpenChanged,
|
isModalOpenChanged,
|
||||||
} from 'features/imageDeletion/store/imageDeletionSlice';
|
} from 'features/imageDeletion/store/imageDeletionSlice';
|
||||||
|
import { nodeEditorReset } from 'features/nodes/store/nodesSlice';
|
||||||
|
import { clearInitialImage } from 'features/parameters/store/generationSlice';
|
||||||
|
import { clamp } from 'lodash-es';
|
||||||
|
import { api } from 'services/api';
|
||||||
|
import { imageDeleted } from 'services/api/thunks/image';
|
||||||
|
import { startAppListening } from '..';
|
||||||
|
|
||||||
const moduleLog = log.child({ namespace: 'image' });
|
const moduleLog = log.child({ namespace: 'image' });
|
||||||
|
|
||||||
@ -37,7 +37,9 @@ export const addRequestedImageDeletionListener = () => {
|
|||||||
state.gallery.selection[state.gallery.selection.length - 1];
|
state.gallery.selection[state.gallery.selection.length - 1];
|
||||||
|
|
||||||
if (lastSelectedImage === image_name) {
|
if (lastSelectedImage === image_name) {
|
||||||
const ids = selectImagesIds(state);
|
const filteredImages = selectFilteredImages(state);
|
||||||
|
|
||||||
|
const ids = filteredImages.map((i) => i.image_name);
|
||||||
|
|
||||||
const deletedImageIndex = ids.findIndex(
|
const deletedImageIndex = ids.findIndex(
|
||||||
(result) => result.toString() === image_name
|
(result) => result.toString() === image_name
|
||||||
|
@ -7,7 +7,6 @@ import {
|
|||||||
import { RootState } from 'app/store/store';
|
import { RootState } from 'app/store/store';
|
||||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||||
import { dateComparator } from 'common/util/dateComparator';
|
import { dateComparator } from 'common/util/dateComparator';
|
||||||
import { imageDeletionConfirmed } from 'features/imageDeletion/store/imageDeletionSlice';
|
|
||||||
import { keyBy, uniq } from 'lodash-es';
|
import { keyBy, uniq } from 'lodash-es';
|
||||||
import { boardsApi } from 'services/api/endpoints/boards';
|
import { boardsApi } from 'services/api/endpoints/boards';
|
||||||
import {
|
import {
|
||||||
@ -174,11 +173,6 @@ export const gallerySlice = createSlice({
|
|||||||
state.limit = limit;
|
state.limit = limit;
|
||||||
state.total = total;
|
state.total = total;
|
||||||
});
|
});
|
||||||
builder.addCase(imageDeletionConfirmed, (state, action) => {
|
|
||||||
// Image deleted
|
|
||||||
const { image_name } = action.payload.imageDTO;
|
|
||||||
imagesAdapter.removeOne(state, image_name);
|
|
||||||
});
|
|
||||||
builder.addCase(imageUrlsReceived.fulfilled, (state, action) => {
|
builder.addCase(imageUrlsReceived.fulfilled, (state, action) => {
|
||||||
const { image_name, image_url, thumbnail_url } = action.payload;
|
const { image_name, image_url, thumbnail_url } = action.payload;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user