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

View File

@ -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<string>('same');
const [customSaveLocation, setCustomSaveLocation] = useState<string>('');
@ -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({