-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add button to clear model cache
- Loading branch information
1 parent
cc9d215
commit 64475b8
Showing
5 changed files
with
65 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
invokeai/frontend/web/src/features/queue/components/ClearModelCacheButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Button } from '@invoke-ai/ui-library'; | ||
import { useFeatureStatus } from 'features/system/hooks/useFeatureStatus'; | ||
import { toast } from 'features/toast/toast'; | ||
import { memo, useCallback } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useEmptyModelCacheMutation } from 'services/api/endpoints/models'; | ||
|
||
const ClearModelCacheButton = () => { | ||
const isModelCacheEnabled = useFeatureStatus('modelCache'); | ||
const [emptyModelCache, { isLoading }] = useEmptyModelCacheMutation(); | ||
const { t } = useTranslation(); | ||
|
||
const handleClearCache = useCallback(async () => { | ||
try { | ||
await emptyModelCache().unwrap(); | ||
toast({ | ||
status: 'success', | ||
title: t('modelCache.clearSucceeded'), | ||
}); | ||
} catch (error) { | ||
toast({ | ||
status: 'error', | ||
title: t('modelCache.clearFailed'), | ||
}); | ||
} | ||
}, [emptyModelCache, t]); | ||
|
||
if (!isModelCacheEnabled) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<Button size="sm" colorScheme="red" onClick={handleClearCache} isLoading={isLoading}> | ||
{t('modelCache.clear')} | ||
</Button> | ||
); | ||
}; | ||
|
||
export default memo(ClearModelCacheButton); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters