mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): deleting board does not reset selected board/image
This commit is contained in:
parent
01b106d939
commit
2c4128d44e
@ -1,5 +1,5 @@
|
|||||||
import type { PayloadAction } from '@reduxjs/toolkit';
|
import type { PayloadAction } from '@reduxjs/toolkit';
|
||||||
import { createSlice } from '@reduxjs/toolkit';
|
import { createSlice, isAnyOf } from '@reduxjs/toolkit';
|
||||||
import { uniq } from 'lodash-es';
|
import { uniq } from 'lodash-es';
|
||||||
import { boardsApi } from 'services/api/endpoints/boards';
|
import { boardsApi } from 'services/api/endpoints/boards';
|
||||||
import { ImageCategory } from 'services/api/types';
|
import { ImageCategory } from 'services/api/types';
|
||||||
@ -44,14 +44,8 @@ export const gallerySlice = createSlice({
|
|||||||
name: 'gallery',
|
name: 'gallery',
|
||||||
initialState: initialGalleryState,
|
initialState: initialGalleryState,
|
||||||
reducers: {
|
reducers: {
|
||||||
imagesRemoved: (state, action: PayloadAction<string[]>) => {
|
|
||||||
// TODO: port all instances of this to use RTK Query cache
|
|
||||||
// imagesAdapter.removeMany(state, action.payload);
|
|
||||||
// state.batchImageNames = state.batchImageNames.filter(
|
|
||||||
// (name) => !action.payload.includes(name)
|
|
||||||
// );
|
|
||||||
},
|
|
||||||
imageRangeEndSelected: (state, action: PayloadAction<string>) => {
|
imageRangeEndSelected: (state, action: PayloadAction<string>) => {
|
||||||
|
// MULTI SELECT LOGIC
|
||||||
// const rangeEndImageName = action.payload;
|
// const rangeEndImageName = action.payload;
|
||||||
// const lastSelectedImage = state.selection[state.selection.length - 1];
|
// const lastSelectedImage = state.selection[state.selection.length - 1];
|
||||||
// const filteredImages = selectFilteredImagesLocal(state);
|
// const filteredImages = selectFilteredImagesLocal(state);
|
||||||
@ -72,6 +66,7 @@ export const gallerySlice = createSlice({
|
|||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
imageSelectionToggled: (state, action: PayloadAction<string>) => {
|
imageSelectionToggled: (state, action: PayloadAction<string>) => {
|
||||||
|
// MULTI SELECT LOGIC
|
||||||
// if (
|
// if (
|
||||||
// state.selection.includes(action.payload) &&
|
// state.selection.includes(action.payload) &&
|
||||||
// state.selection.length > 1
|
// state.selection.length > 1
|
||||||
@ -135,9 +130,7 @@ export const gallerySlice = createSlice({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
extraReducers: (builder) => {
|
extraReducers: (builder) => {
|
||||||
builder.addMatcher(
|
builder.addMatcher(isAnyBoardDeleted, (state, action) => {
|
||||||
boardsApi.endpoints.deleteBoard.matchFulfilled,
|
|
||||||
(state, action) => {
|
|
||||||
const deletedBoardId = action.meta.arg.originalArgs;
|
const deletedBoardId = action.meta.arg.originalArgs;
|
||||||
if (deletedBoardId === state.selectedBoardId) {
|
if (deletedBoardId === state.selectedBoardId) {
|
||||||
state.selectedBoardId = undefined;
|
state.selectedBoardId = undefined;
|
||||||
@ -146,8 +139,7 @@ export const gallerySlice = createSlice({
|
|||||||
if (deletedBoardId === state.autoAddBoardId) {
|
if (deletedBoardId === state.autoAddBoardId) {
|
||||||
state.autoAddBoardId = undefined;
|
state.autoAddBoardId = undefined;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
builder.addMatcher(
|
builder.addMatcher(
|
||||||
boardsApi.endpoints.listAllBoards.matchFulfilled,
|
boardsApi.endpoints.listAllBoards.matchFulfilled,
|
||||||
(state, action) => {
|
(state, action) => {
|
||||||
@ -180,3 +172,8 @@ export const {
|
|||||||
} = gallerySlice.actions;
|
} = gallerySlice.actions;
|
||||||
|
|
||||||
export default gallerySlice.reducer;
|
export default gallerySlice.reducer;
|
||||||
|
|
||||||
|
const isAnyBoardDeleted = isAnyOf(
|
||||||
|
boardsApi.endpoints.deleteBoard.matchFulfilled,
|
||||||
|
boardsApi.endpoints.deleteBoardAndImages.matchFulfilled
|
||||||
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user