perf: 未更新信息时也能保存

This commit is contained in:
archer
2023-04-06 16:12:36 +08:00
parent 881c36542c
commit 9a45fb64c2

View File

@@ -80,19 +80,21 @@ const InputDataModal = ({
const updateData = useCallback(
async (e: FormData) => {
if (!e.dataId) return;
if (e.text === defaultValues.text && e.q === defaultValues.q) return;
await putModelDataById({
dataId: e.dataId,
text: e.text,
q: e.q === defaultValues.q ? '' : e.q
});
if (e.text !== defaultValues.text || e.q !== defaultValues.q) {
await putModelDataById({
dataId: e.dataId,
text: e.text,
q: e.q === defaultValues.q ? '' : e.q
});
onSuccess();
}
toast({
title: '修改回答成功',
status: 'success'
});
onClose();
onSuccess();
},
[defaultValues, onClose, onSuccess, toast]
);