fix(ui): edge case resulting in no node templates when loading workflow, causing failure

Depending on the user behaviour and network conditions, it's possible that we could try to load a workflow before the invocation templates are available.

Fix is simple:
- Use the RTKQ query hook for openAPI schema in App.tsx
- Disable the load workflow buttons until w have templates parsed
This commit is contained in:
psychedelicious
2024-05-19 23:44:07 +10:00
committed by Kent Keirsey
parent ca186bca61
commit ba8bed6870
4 changed files with 16 additions and 4 deletions

View File

@@ -1,15 +1,19 @@
import { MenuItem } from '@invoke-ai/ui-library';
import { useStore } from '@nanostores/react';
import { $templates } from 'features/nodes/store/nodesSlice';
import { useLoadWorkflowFromGraphModal } from 'features/workflowLibrary/components/LoadWorkflowFromGraphModal/LoadWorkflowFromGraphModal';
import { size } from 'lodash-es';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import { PiFlaskBold } from 'react-icons/pi';
const LoadWorkflowFromGraphMenuItem = () => {
const { t } = useTranslation();
const templates = useStore($templates);
const { onOpen } = useLoadWorkflowFromGraphModal();
return (
<MenuItem as="button" icon={<PiFlaskBold />} onClick={onOpen}>
<MenuItem as="button" icon={<PiFlaskBold />} onClick={onOpen} isDisabled={!size(templates)}>
{t('workflows.loadFromGraph')}
</MenuItem>
);