From 3c7cf7242365576c481f4170b3ffa6ee0ca3f05d Mon Sep 17 00:00:00 2001 From: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com> Date: Sat, 15 Jul 2023 01:29:51 +1200 Subject: [PATCH] fix: Clean up merge models submit handler --- .../subpanels/MergeModelsPanel.tsx | 50 +++++++++---------- .../ModelManagerPanel/ModelConvert.tsx | 9 ++-- 2 files changed, 29 insertions(+), 30 deletions(-) diff --git a/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/MergeModelsPanel.tsx b/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/MergeModelsPanel.tsx index bf9ede9874..b2d88802c9 100644 --- a/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/MergeModelsPanel.tsx +++ b/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/MergeModelsPanel.tsx @@ -43,8 +43,7 @@ export default function MergeModelsPanel() { const { data } = useGetMainModelsQuery(); - const [mergeModels, { isLoading, error, data: mergedModelData }] = - useMergeMainModelsMutation(); + const [mergeModels, { isLoading }] = useMergeMainModelsMutation(); const [baseModel, setBaseModel] = useState('sd-1'); @@ -134,29 +133,30 @@ export default function MergeModelsPanel() { mergeModels({ base_model: baseModel, body: mergeModelsInfo, - }); - - if (error) { - dispatch( - addToast( - makeToast({ - title: t('modelManager.modelsMergeFailed'), - status: 'error', - }) - ) - ); - } - - if (mergedModelData) { - dispatch( - addToast( - makeToast({ - title: t('modelManager.modelsMerged'), - status: 'success', - }) - ) - ); - } + }) + .unwrap() + .then((_) => { + dispatch( + addToast( + makeToast({ + title: t('modelManager.modelsMerged'), + status: 'success', + }) + ) + ); + }) + .catch((error) => { + if (error) { + dispatch( + addToast( + makeToast({ + title: t('modelManager.modelsMergeFailed'), + status: 'error', + }) + ) + ); + } + }); }; return ( diff --git a/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/ModelManagerPanel/ModelConvert.tsx b/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/ModelManagerPanel/ModelConvert.tsx index 5df7631772..922fdacee7 100644 --- a/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/ModelManagerPanel/ModelConvert.tsx +++ b/invokeai/frontend/web/src/features/ui/components/tabs/ModelManager/subpanels/ModelManagerPanel/ModelConvert.tsx @@ -9,7 +9,7 @@ import { useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { useConvertMainModelsMutation } from 'services/api/endpoints/models'; -import { CheckpointModelConfig } from './CheckpointModelEdit'; +import { CheckpointModelConfig } from 'services/api/types'; interface ModelConvertProps { model: CheckpointModelConfig; @@ -21,8 +21,7 @@ export default function ModelConvert(props: ModelConvertProps) { const dispatch = useAppDispatch(); const { t } = useTranslation(); - const [convertModel, { isLoading, error, data }] = - useConvertMainModelsMutation(); + const [convertModel, { isLoading }] = useConvertMainModelsMutation(); const [saveLocation, setSaveLocation] = useState('same'); const [customSaveLocation, setCustomSaveLocation] = useState(''); @@ -42,7 +41,7 @@ export default function ModelConvert(props: ModelConvertProps) { }; convertModel(responseBody) .unwrap() - .then((payload) => { + .then((_) => { dispatch( addToast( makeToast({ @@ -52,7 +51,7 @@ export default function ModelConvert(props: ModelConvertProps) { ) ); }) - .catch((error) => { + .catch((_) => { dispatch( addToast( makeToast({