mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
fix(ui): update boardIdSelected
This commit is contained in:
parent
4da6623700
commit
f4e8a91bcf
@ -1,20 +1,20 @@
|
|||||||
import { log } from 'app/logging/useLogger';
|
import { log } from 'app/logging/useLogger';
|
||||||
import {
|
import {
|
||||||
|
ASSETS_CATEGORIES,
|
||||||
|
IMAGE_CATEGORIES,
|
||||||
boardIdSelected,
|
boardIdSelected,
|
||||||
|
galleryViewChanged,
|
||||||
imageSelected,
|
imageSelected,
|
||||||
} from 'features/gallery/store/gallerySlice';
|
} from 'features/gallery/store/gallerySlice';
|
||||||
import {
|
|
||||||
getBoardIdQueryParamForBoard,
|
|
||||||
getCategoriesQueryParamForBoard,
|
|
||||||
} from 'features/gallery/store/util';
|
|
||||||
import { imagesApi } from 'services/api/endpoints/images';
|
import { imagesApi } from 'services/api/endpoints/images';
|
||||||
import { startAppListening } from '..';
|
import { startAppListening } from '..';
|
||||||
|
import { isAnyOf } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
const moduleLog = log.child({ namespace: 'boards' });
|
const moduleLog = log.child({ namespace: 'boards' });
|
||||||
|
|
||||||
export const addBoardIdSelectedListener = () => {
|
export const addBoardIdSelectedListener = () => {
|
||||||
startAppListening({
|
startAppListening({
|
||||||
actionCreator: boardIdSelected,
|
matcher: isAnyOf(boardIdSelected, galleryViewChanged),
|
||||||
effect: async (
|
effect: async (
|
||||||
action,
|
action,
|
||||||
{ getState, dispatch, condition, cancelActiveListeners }
|
{ getState, dispatch, condition, cancelActiveListeners }
|
||||||
@ -22,12 +22,21 @@ export const addBoardIdSelectedListener = () => {
|
|||||||
// Cancel any in-progress instances of this listener, we don't want to select an image from a previous board
|
// Cancel any in-progress instances of this listener, we don't want to select an image from a previous board
|
||||||
cancelActiveListeners();
|
cancelActiveListeners();
|
||||||
|
|
||||||
const _board_id = action.payload;
|
const state = getState();
|
||||||
// when a board is selected, we need to wait until the board has loaded *some* images, then select the first one
|
|
||||||
|
|
||||||
const categories = getCategoriesQueryParamForBoard(_board_id);
|
const board_id = boardIdSelected.match(action)
|
||||||
const board_id = getBoardIdQueryParamForBoard(_board_id);
|
? action.payload
|
||||||
const queryArgs = { board_id, categories };
|
: state.gallery.selectedBoardId;
|
||||||
|
|
||||||
|
const galleryView = galleryViewChanged.match(action)
|
||||||
|
? action.payload
|
||||||
|
: state.gallery.galleryView;
|
||||||
|
|
||||||
|
// when a board is selected, we need to wait until the board has loaded *some* images, then select the first one
|
||||||
|
const categories =
|
||||||
|
galleryView === 'images' ? IMAGE_CATEGORIES : ASSETS_CATEGORIES;
|
||||||
|
|
||||||
|
const queryArgs = { board_id: board_id ?? 'none', categories };
|
||||||
|
|
||||||
// wait until the board has some images - maybe it already has some from a previous fetch
|
// wait until the board has some images - maybe it already has some from a previous fetch
|
||||||
// must use getState() to ensure we do not have stale state
|
// must use getState() to ensure we do not have stale state
|
||||||
|
Loading…
x
Reference in New Issue
Block a user