mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-13 13:55:08 -05:00
refactor(ui): migrate from canceling queue items to deleteing, make queue hook APIs consistent
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { toast } from 'features/toast/toast';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import { useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useEnableInvocationCacheMutation, useGetInvocationCacheStatusQuery } from 'services/api/endpoints/appInfo';
|
||||
import { $isConnected } from 'services/events/stores';
|
||||
@@ -9,22 +9,13 @@ export const useEnableInvocationCache = () => {
|
||||
const { t } = useTranslation();
|
||||
const { data: cacheStatus } = useGetInvocationCacheStatusQuery();
|
||||
const isConnected = useStore($isConnected);
|
||||
const [trigger, { isLoading }] = useEnableInvocationCacheMutation({
|
||||
const [_trigger, { isLoading }] = useEnableInvocationCacheMutation({
|
||||
fixedCacheKey: 'enableInvocationCache',
|
||||
});
|
||||
|
||||
const isDisabled = useMemo(
|
||||
() => cacheStatus?.enabled || !isConnected || cacheStatus?.max_size === 0,
|
||||
[cacheStatus?.enabled, cacheStatus?.max_size, isConnected]
|
||||
);
|
||||
|
||||
const enableInvocationCache = useCallback(async () => {
|
||||
if (isDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
const trigger = useCallback(async () => {
|
||||
try {
|
||||
await trigger().unwrap();
|
||||
await _trigger().unwrap();
|
||||
toast({
|
||||
id: 'INVOCATION_CACHE_ENABLE_SUCCEEDED',
|
||||
title: t('invocationCache.enableSucceeded'),
|
||||
@@ -37,7 +28,11 @@ export const useEnableInvocationCache = () => {
|
||||
status: 'error',
|
||||
});
|
||||
}
|
||||
}, [isDisabled, trigger, t]);
|
||||
}, [_trigger, t]);
|
||||
|
||||
return { enableInvocationCache, isLoading, cacheStatus, isDisabled };
|
||||
return {
|
||||
trigger,
|
||||
isLoading,
|
||||
isDisabled: cacheStatus?.enabled || !isConnected || cacheStatus?.max_size === 0,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user