From 1419977e8943ce56341f7ee5799253da06732048 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:39:54 +1000 Subject: [PATCH] feat(ui): update cache status on queue event It was polling every 5s before. No need - just invalidate the tag when we have a queue item status change event. --- .../socketio/socketQueueItemStatusChanged.ts | 1 + .../queue/components/InvocationCacheStatus.tsx | 13 +------------ 2 files changed, 2 insertions(+), 12 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 b0377e950b..4af35dbe9c 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 @@ -35,6 +35,7 @@ export const addSocketQueueItemStatusChangedEventListener = () => { queueApi.util.invalidateTags([ 'CurrentSessionQueueItem', 'NextSessionQueueItem', + 'InvocationCacheStatus', { type: 'SessionQueueItem', id: item_id }, { type: 'SessionQueueItemDTO', id: item_id }, { type: 'BatchStatus', id: queue_batch_id }, diff --git a/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx b/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx index 423ab09376..1720f81285 100644 --- a/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx +++ b/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx @@ -1,9 +1,7 @@ import { ButtonGroup } from '@chakra-ui/react'; -import { useAppSelector } from 'app/store/storeHooks'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import { useGetInvocationCacheStatusQuery } from 'services/api/endpoints/appInfo'; -import { useGetQueueStatusQuery } from 'services/api/endpoints/queue'; import ClearInvocationCacheButton from './ClearInvocationCacheButton'; import ToggleInvocationCacheButton from './ToggleInvocationCacheButton'; import StatusStatGroup from './common/StatusStatGroup'; @@ -11,16 +9,7 @@ import StatusStatItem from './common/StatusStatItem'; const InvocationCacheStatus = () => { const { t } = useTranslation(); - const isConnected = useAppSelector((state) => state.system.isConnected); - const { data: queueStatus } = useGetQueueStatusQuery(undefined); - const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined, { - pollingInterval: - isConnected && - queueStatus?.processor.is_started && - queueStatus?.queue.pending > 0 - ? 5000 - : 0, - }); + const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined); return (