Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

949 B
Raw Blame
import { Button } from '@invoke-ai/ui-library';
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 [emptyModelCache, { isLoading }] = useEmptyModelCacheMutation();
  const { t } = useTranslation();

  const handleClearCache = useCallback(async () => {
    try {
      await emptyModelCache().unwrap();
      toast({
        status: 'success',
        title: t('modelCache.clearSucceeded'),
      });
    } catch {
      toast({
        status: 'error',
        title: t('modelCache.clearFailed'),
      });
    }
  }, [emptyModelCache, t]);

  return (
    <Button size="sm" colorScheme="red" onClick={handleClearCache} isLoading={isLoading}>
      {t('modelCache.clear')}
    </Button>
  );
};

export default memo(ClearModelCacheButton);