fix: Clean up merge models submit handler

This commit is contained in:
blessedcoolant 2023-07-15 01:29:51 +12:00
parent 2a533b275f
commit 3c7cf72423
2 changed files with 29 additions and 30 deletions

View File

@ -43,8 +43,7 @@ export default function MergeModelsPanel() {
const { data } = useGetMainModelsQuery(); const { data } = useGetMainModelsQuery();
const [mergeModels, { isLoading, error, data: mergedModelData }] = const [mergeModels, { isLoading }] = useMergeMainModelsMutation();
useMergeMainModelsMutation();
const [baseModel, setBaseModel] = useState<BaseModelType>('sd-1'); const [baseModel, setBaseModel] = useState<BaseModelType>('sd-1');
@ -134,29 +133,30 @@ export default function MergeModelsPanel() {
mergeModels({ mergeModels({
base_model: baseModel, base_model: baseModel,
body: mergeModelsInfo, body: mergeModelsInfo,
}); })
.unwrap()
if (error) { .then((_) => {
dispatch( dispatch(
addToast( addToast(
makeToast({ makeToast({
title: t('modelManager.modelsMergeFailed'), title: t('modelManager.modelsMerged'),
status: 'error', status: 'success',
}) })
) )
); );
} })
.catch((error) => {
if (mergedModelData) { if (error) {
dispatch( dispatch(
addToast( addToast(
makeToast({ makeToast({
title: t('modelManager.modelsMerged'), title: t('modelManager.modelsMergeFailed'),
status: 'success', status: 'error',
}) })
) )
); );
} }
});
}; };
return ( return (

View File

@ -9,7 +9,7 @@ import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useConvertMainModelsMutation } from 'services/api/endpoints/models'; import { useConvertMainModelsMutation } from 'services/api/endpoints/models';
import { CheckpointModelConfig } from './CheckpointModelEdit'; import { CheckpointModelConfig } from 'services/api/types';
interface ModelConvertProps { interface ModelConvertProps {
model: CheckpointModelConfig; model: CheckpointModelConfig;
@ -21,8 +21,7 @@ export default function ModelConvert(props: ModelConvertProps) {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation(); const { t } = useTranslation();
const [convertModel, { isLoading, error, data }] = const [convertModel, { isLoading }] = useConvertMainModelsMutation();
useConvertMainModelsMutation();
const [saveLocation, setSaveLocation] = useState<string>('same'); const [saveLocation, setSaveLocation] = useState<string>('same');
const [customSaveLocation, setCustomSaveLocation] = useState<string>(''); const [customSaveLocation, setCustomSaveLocation] = useState<string>('');
@ -42,7 +41,7 @@ export default function ModelConvert(props: ModelConvertProps) {
}; };
convertModel(responseBody) convertModel(responseBody)
.unwrap() .unwrap()
.then((payload) => { .then((_) => {
dispatch( dispatch(
addToast( addToast(
makeToast({ makeToast({
@ -52,7 +51,7 @@ export default function ModelConvert(props: ModelConvertProps) {
) )
); );
}) })
.catch((error) => { .catch((_) => {
dispatch( dispatch(
addToast( addToast(
makeToast({ makeToast({