Skip to content

Commit b95b9a1

Browse files
author
Attila Cseh
committed
selectAllQueueItems selector memoization fixed
1 parent 65d2011 commit b95b9a1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

invokeai/frontend/web/src/features/controlLayers/components/StagingArea/context.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ export const StagingAreaContextProvider = memo(({ children }: PropsWithChildren)
3434

3535
const stagingAreaAppApi = useMemo<StagingAreaAppApi>(() => {
3636
const _stagingAreaAppApi: StagingAreaAppApi = {
37-
getAutoSwitch: () => {
38-
return selectStagingAreaAutoSwitch(store.getState());
39-
},
37+
getAutoSwitch: () => selectStagingAreaAutoSwitch(store.getState()),
4038
getImageDTO: (imageName: string) => getImageDTOSafe(imageName),
4139
onInvocationProgress: (handler) => {
4240
socket?.on('invocation_progress', handler);
@@ -68,6 +66,7 @@ export const StagingAreaContextProvider = memo(({ children }: PropsWithChildren)
6866
},
6967
onDiscardAll: () => {
7068
store.dispatch(canvasSessionReset());
69+
7170
if (sessionId) {
7271
store.dispatch(
7372
queueApi.endpoints.cancelQueueItemsByDestination.initiate({ destination: sessionId }, { track: false })
@@ -86,6 +85,7 @@ export const StagingAreaContextProvider = memo(({ children }: PropsWithChildren)
8685

8786
store.dispatch(rasterLayerAdded({ overrides, isSelected: selectedEntityIdentifier?.type === 'raster_layer' }));
8887
store.dispatch(canvasSessionReset());
88+
8989
if (sessionId) {
9090
store.dispatch(
9191
queueApi.endpoints.cancelQueueItemsByDestination.initiate({ destination: sessionId }, { track: false })

invokeai/frontend/web/src/features/controlLayers/store/canvasStagingAreaSlice.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ export const selectActiveCanvasStagingAreaSessionId = (state: RootState) => {
6666
const session = selectActiveCanvasStagingArea(state);
6767
return session.canvasSessionId;
6868
};
69-
const selectAllQueueItems = createSelector(
70-
(state: RootState) => state,
71-
(_state: RootState, sessionId: string) => sessionId,
72-
(state, sessionId) => queueApi.endpoints.listAllQueueItems.select({ destination: sessionId })(state)
69+
const createAllQueueItemsSelector = createSelector(
70+
(sessionId: string) => sessionId,
71+
(sessionId) => queueApi.endpoints.listAllQueueItems.select({ destination: sessionId })
7372
);
7473
const selectCanvasQueueItemsBySessionId = createSelector(
75-
selectAllQueueItems,
74+
(state: RootState, sessionId: string) => createAllQueueItemsSelector(sessionId)(state),
7675
(state: RootState, sessionId: string) => selectCanvasStagingAreaBySessionId(state, sessionId),
7776
({ data }, session) => {
7877
if (!data) {

0 commit comments

Comments
 (0)