From f1bb7e86c008fc6edfe1c11fe86c8caefeb52274 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Mon, 20 May 2024 18:23:01 +1000 Subject: [PATCH] feat(ui): invalidate cache for queue item on status change This query is only subscribed-to in the `QueueItemDetail` component - when is rendered only when the user clicks on a queue item in the queue. Invalidating this tag instead of optimistically updating it won't cause any meaningful change to network traffic. --- .../socketio/socketQueueItemStatusChanged.ts | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts index 2adc529766..3b274b2889 100644 --- a/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts +++ b/invokeai/frontend/web/src/app/store/middleware/listenerMiddleware/listeners/socketio/socketQueueItemStatusChanged.ts @@ -43,20 +43,15 @@ export const addSocketQueueItemStatusChangedEventListener = (startAppListening: queueApi.util.updateQueryData('getBatchStatus', { batch_id: batch_status.batch_id }, () => batch_status) ); - // Update the queue item status (this is the full queue item, including the session) - dispatch( - queueApi.util.updateQueryData('getQueueItem', queue_item.item_id, (draft) => { - if (!draft) { - return; - } - Object.assign(draft, queue_item); - }) - ); - // Invalidate caches for things we cannot update // TODO: technically, we could possibly update the current session queue item, but feels safer to just request it again dispatch( - queueApi.util.invalidateTags(['CurrentSessionQueueItem', 'NextSessionQueueItem', 'InvocationCacheStatus']) + queueApi.util.invalidateTags([ + 'CurrentSessionQueueItem', + 'NextSessionQueueItem', + 'InvocationCacheStatus', + { type: 'SessionQueueItem', id: queue_item.item_id }, + ]) ); if (['in_progress'].includes(action.payload.data.queue_item.status)) {