From 6a4c77e3b452701fa5ba337fa54d1573a609fcd3 Mon Sep 17 00:00:00 2001 From: Mary Hipp Date: Thu, 15 Feb 2024 15:59:54 -0500 Subject: [PATCH] only ever get cache status if feature is enabled --- .../src/features/queue/components/InvocationCacheStatus.tsx | 4 +++- .../features/queue/components/ToggleInvocationCacheButton.tsx | 4 +++- .../web/src/features/queue/hooks/useClearInvocationCache.ts | 4 +++- .../web/src/features/queue/hooks/useDisableInvocationCache.ts | 4 +++- .../web/src/features/queue/hooks/useEnableInvocationCache.ts | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx b/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx index 9ce334c996..48514fef29 100644 --- a/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx +++ b/invokeai/frontend/web/src/features/queue/components/InvocationCacheStatus.tsx @@ -1,4 +1,5 @@ import { ButtonGroup } from '@invoke-ai/ui-library'; +import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import { useGetInvocationCacheStatusQuery } from 'services/api/endpoints/appInfo'; @@ -10,7 +11,8 @@ import ToggleInvocationCacheButton from './ToggleInvocationCacheButton'; const InvocationCacheStatus = () => { const { t } = useTranslation(); - const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined); + const isCacheEnabled = useFeatureStatus('invocationCache').isFeatureEnabled; + const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined, { skip: isCacheEnabled }); return ( diff --git a/invokeai/frontend/web/src/features/queue/components/ToggleInvocationCacheButton.tsx b/invokeai/frontend/web/src/features/queue/components/ToggleInvocationCacheButton.tsx index 1720e6a69d..3cd9d5a8ba 100644 --- a/invokeai/frontend/web/src/features/queue/components/ToggleInvocationCacheButton.tsx +++ b/invokeai/frontend/web/src/features/queue/components/ToggleInvocationCacheButton.tsx @@ -1,13 +1,15 @@ import { Button } from '@invoke-ai/ui-library'; import { useDisableInvocationCache } from 'features/queue/hooks/useDisableInvocationCache'; import { useEnableInvocationCache } from 'features/queue/hooks/useEnableInvocationCache'; +import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; import { memo } from 'react'; import { useTranslation } from 'react-i18next'; import { useGetInvocationCacheStatusQuery } from 'services/api/endpoints/appInfo'; const ToggleInvocationCacheButton = () => { const { t } = useTranslation(); - const { data: cacheStatus } = useGetInvocationCacheStatusQuery(); + const isCacheEnabled = useFeatureStatus('invocationCache').isFeatureEnabled; + const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined, { skip: isCacheEnabled }); const { enableInvocationCache, diff --git a/invokeai/frontend/web/src/features/queue/hooks/useClearInvocationCache.ts b/invokeai/frontend/web/src/features/queue/hooks/useClearInvocationCache.ts index 34b46d79b4..657f5ae847 100644 --- a/invokeai/frontend/web/src/features/queue/hooks/useClearInvocationCache.ts +++ b/invokeai/frontend/web/src/features/queue/hooks/useClearInvocationCache.ts @@ -1,4 +1,5 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; +import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; import { addToast } from 'features/system/store/systemSlice'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -7,7 +8,8 @@ import { useClearInvocationCacheMutation, useGetInvocationCacheStatusQuery } fro export const useClearInvocationCache = () => { const { t } = useTranslation(); const dispatch = useAppDispatch(); - const { data: cacheStatus } = useGetInvocationCacheStatusQuery(); + const isCacheEnabled = useFeatureStatus('invocationCache').isFeatureEnabled; + const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined, { skip: isCacheEnabled }); const isConnected = useAppSelector((s) => s.system.isConnected); const [trigger, { isLoading }] = useClearInvocationCacheMutation({ fixedCacheKey: 'clearInvocationCache', diff --git a/invokeai/frontend/web/src/features/queue/hooks/useDisableInvocationCache.ts b/invokeai/frontend/web/src/features/queue/hooks/useDisableInvocationCache.ts index c7d5a575d2..8ac546502c 100644 --- a/invokeai/frontend/web/src/features/queue/hooks/useDisableInvocationCache.ts +++ b/invokeai/frontend/web/src/features/queue/hooks/useDisableInvocationCache.ts @@ -1,4 +1,5 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; +import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; import { addToast } from 'features/system/store/systemSlice'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -7,7 +8,8 @@ import { useDisableInvocationCacheMutation, useGetInvocationCacheStatusQuery } f export const useDisableInvocationCache = () => { const { t } = useTranslation(); const dispatch = useAppDispatch(); - const { data: cacheStatus } = useGetInvocationCacheStatusQuery(); + const isCacheEnabled = useFeatureStatus('invocationCache').isFeatureEnabled; + const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined, { skip: isCacheEnabled }); const isConnected = useAppSelector((s) => s.system.isConnected); const [trigger, { isLoading }] = useDisableInvocationCacheMutation({ fixedCacheKey: 'disableInvocationCache', diff --git a/invokeai/frontend/web/src/features/queue/hooks/useEnableInvocationCache.ts b/invokeai/frontend/web/src/features/queue/hooks/useEnableInvocationCache.ts index 22bb7aa97d..3b7e8165fb 100644 --- a/invokeai/frontend/web/src/features/queue/hooks/useEnableInvocationCache.ts +++ b/invokeai/frontend/web/src/features/queue/hooks/useEnableInvocationCache.ts @@ -1,4 +1,5 @@ import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; +import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; import { addToast } from 'features/system/store/systemSlice'; import { useCallback, useMemo } from 'react'; import { useTranslation } from 'react-i18next'; @@ -7,7 +8,8 @@ import { useEnableInvocationCacheMutation, useGetInvocationCacheStatusQuery } fr export const useEnableInvocationCache = () => { const { t } = useTranslation(); const dispatch = useAppDispatch(); - const { data: cacheStatus } = useGetInvocationCacheStatusQuery(); + const isCacheEnabled = useFeatureStatus('invocationCache').isFeatureEnabled; + const { data: cacheStatus } = useGetInvocationCacheStatusQuery(undefined, { skip: isCacheEnabled }); const isConnected = useAppSelector((s) => s.system.isConnected); const [trigger, { isLoading }] = useEnableInvocationCacheMutation({ fixedCacheKey: 'enableInvocationCache',