Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): gallery followups #6601

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,13 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
return;
}

let didReset = false;

if (!queryResult.data.find((board) => board.board_id === autoAddBoardId)) {
dispatch(autoAddBoardIdChanged('none'));
didReset = true;
}
if (!queryResult.data.find((board) => board.board_id === selectedBoardId)) {
dispatch(boardIdSelected({ boardId: 'none' }));
didReset = true;
}
if (didReset) {
dispatch(galleryViewChanged('images'));
}
if (!queryResult.data.find((board) => board.board_id === autoAddBoardId)) {
dispatch(autoAddBoardIdChanged('none'));
}
},
});

Expand Down Expand Up @@ -90,25 +84,17 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
return;
}

let didReset = false;

// Handle the case where selected board is archived
const selectedBoard = queryResult.data.find((b) => b.board_id === selectedBoardId);
if (selectedBoard && selectedBoard.archived) {
dispatch(boardIdSelected({ boardId: 'none' }));
didReset = true;
dispatch(galleryViewChanged('images'));
}

// Handle the case where auto-add board is archived
const autoAddBoard = queryResult.data.find((b) => b.board_id === autoAddBoardId);
if (autoAddBoard && autoAddBoard.archived) {
dispatch(autoAddBoardIdChanged('none'));
didReset = true;
}

// When resetting the auto-add board or selected board, we should also reset the view to images
if (didReset) {
dispatch(galleryViewChanged('images'));
}
},
});
Expand All @@ -123,25 +109,15 @@ export const addArchivedOrDeletedBoardListener = (startAppListening: AppStartLis
const state = getState();
const { selectedBoardId, autoAddBoardId } = state.gallery;

let didReset = false;

// Handle the case where selected board isn't in the list of boards
const selectedBoard = boards.find((b) => b.board_id === selectedBoardId);
if (selectedBoard && selectedBoard.archived) {
if (!boards.find((b) => b.board_id === selectedBoardId)) {
dispatch(boardIdSelected({ boardId: 'none' }));
didReset = true;
dispatch(galleryViewChanged('images'));
}

// Handle the case where auto-add board isn't in the list of boards
const autoAddBoard = boards.find((b) => b.board_id === autoAddBoardId);
if (autoAddBoard && autoAddBoard.archived) {
if (!boards.find((b) => b.board_id === autoAddBoardId)) {
dispatch(autoAddBoardIdChanged('none'));
didReset = true;
}

// When resetting the auto-add board or selected board, we should also reset the view to images
if (didReset) {
dispatch(galleryViewChanged('images'));
}
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const BoardsList = () => {
</Flex>
</Flex>
)}
<Flex direction="column" gap={1}>
<Flex direction="column" gap={1} pb={2}>
<Flex
position="sticky"
w="full"
Expand Down
9 changes: 4 additions & 5 deletions invokeai/frontend/web/src/services/api/endpoints/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ export const imagesApi = api.injectEndpoints({
const boardId = imageDTO.board_id ?? 'none';

return [
{ type: 'Image', id: imageDTO.image_name },
{
type: 'ImageList',
id: getListImagesUrl({
Expand Down Expand Up @@ -138,9 +137,6 @@ export const imagesApi = api.injectEndpoints({
id: boardId,
},
];
for (const imageDTO of imageDTOs) {
tags.push({ type: 'Image', id: imageDTO.image_name });
}

return tags;
}
Expand Down Expand Up @@ -508,7 +504,6 @@ export const imagesApi = api.injectEndpoints({
export const {
useGetIntermediatesCountQuery,
useListImagesQuery,
useGetImageDTOQuery,
useGetImageMetadataQuery,
useGetImageWorkflowQuery,
useLazyGetImageWorkflowQuery,
Expand All @@ -526,6 +521,10 @@ export const {
useBulkDownloadImagesMutation,
} = imagesApi;

export const useGetImageDTOQuery = (...args: Parameters<typeof imagesApi.useGetImageDTOQuery>) => {
return imagesApi.useGetImageDTOQuery(...args);
};

/**
* Imperative RTKQ helper to fetch an ImageDTO.
* @param image_name The name of the image to fetch
Expand Down
Loading