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.

2.0 KB
Raw Blame
import { Alert, AlertDescription, AlertIcon, AlertTitle } from '@invoke-ai/ui-library';
import { useStore } from '@nanostores/react';
import { useAppSelector } from 'app/store/storeHooks';
import { useDeferredModelLoadingInvocationProgressMessage } from 'features/controlLayers/hooks/useDeferredModelLoadingInvocationProgressMessage';
import { selectSystemShouldShowInvocationProgressDetail } from 'features/system/store/systemSlice';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { $lastProgressMessage } from 'services/events/stores';

const CanvasAlertsInvocationProgressContentLocal = memo(() => {
  const { t } = useTranslation();
  const invocationProgressMessage = useStore($lastProgressMessage);

  if (!invocationProgressMessage) {
    return null;
  }

  return (
    <Alert status="loading" borderRadius="base" fontSize="sm" shadow="md" w="fit-content">
      <AlertIcon />
      <AlertTitle>{t('common.generating')}</AlertTitle>
      <AlertDescription>{invocationProgressMessage}</AlertDescription>
    </Alert>
  );
});
CanvasAlertsInvocationProgressContentLocal.displayName = 'CanvasAlertsInvocationProgressContentLocal';

const CanvasAlertsInvocationProgressContentCommercial = memo(() => {
  const message = useDeferredModelLoadingInvocationProgressMessage();

  if (!message) {
    return null;
  }

  return (
    <Alert status="loading" borderRadius="base" fontSize="sm" shadow="md" w="fit-content">
      <AlertIcon />
      <AlertDescription>{message}</AlertDescription>
    </Alert>
  );
});
CanvasAlertsInvocationProgressContentCommercial.displayName = 'CanvasAlertsInvocationProgressContentCommercial';

export const CanvasAlertsInvocationProgress = memo(() => {
  const shouldShowInvocationProgressDetail = useAppSelector(selectSystemShouldShowInvocationProgressDetail);

  // user setting
  if (!shouldShowInvocationProgressDetail) {
    return null;
  }

  return <CanvasAlertsInvocationProgressContentLocal />;
});

CanvasAlertsInvocationProgress.displayName = 'CanvasAlertsInvocationProgress';