mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 07:45:47 +00:00
Merge branch 'fix/recording' into 'development'
[FIX/FE] Recording See merge request mbugroup/lti-web-client!369
This commit is contained in:
@@ -566,24 +566,32 @@ const useSelect = <T,>(
|
|||||||
setSize(size + 1);
|
setSize(size + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
let formattedSuccessRawData: SuccessApiResponse<T[]> | undefined = undefined;
|
|
||||||
let formattedErrorRawData: ErrorApiResponse | undefined = undefined;
|
|
||||||
|
|
||||||
const latestPagesIndex = pages?.length ? pages.length - 1 : 0;
|
const latestPagesIndex = pages?.length ? pages.length - 1 : 0;
|
||||||
|
|
||||||
|
const { formattedSuccessRawData, formattedErrorRawData } = useMemo(() => {
|
||||||
|
let successData: SuccessApiResponse<T[]> | undefined = undefined;
|
||||||
|
let errorData: ErrorApiResponse | undefined = undefined;
|
||||||
|
|
||||||
if (isResponseSuccess(pages?.[latestPagesIndex])) {
|
if (isResponseSuccess(pages?.[latestPagesIndex])) {
|
||||||
formattedSuccessRawData = {
|
successData = {
|
||||||
...pages?.[latestPagesIndex],
|
...pages![latestPagesIndex],
|
||||||
data:
|
data:
|
||||||
pages?.flatMap((page) => (isResponseSuccess(page) ? page.data : [])) ??
|
pages?.flatMap((page) =>
|
||||||
[],
|
isResponseSuccess(page) ? page.data : []
|
||||||
|
) ?? [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isResponseError(pages?.[latestPagesIndex])) {
|
if (isResponseError(pages?.[latestPagesIndex])) {
|
||||||
formattedErrorRawData = pages?.[latestPagesIndex];
|
errorData = pages![latestPagesIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
formattedSuccessRawData: successData,
|
||||||
|
formattedErrorRawData: errorData,
|
||||||
|
};
|
||||||
|
}, [pages, latestPagesIndex]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
inputValue,
|
inputValue,
|
||||||
setInputValue,
|
setInputValue,
|
||||||
|
|||||||
@@ -974,10 +974,18 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next[item.id] !== item) {
|
const existing = next[item.id];
|
||||||
|
if (existing !== item) {
|
||||||
|
// Check deep equality to avoid triggering state changes
|
||||||
|
// when identical data comes from different sources (e.g. initialValues vs SWR)
|
||||||
|
if (
|
||||||
|
!existing ||
|
||||||
|
JSON.stringify(existing) !== JSON.stringify(item)
|
||||||
|
) {
|
||||||
next[item.id] = item;
|
next[item.id] = item;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return changed ? next : prev;
|
return changed ? next : prev;
|
||||||
|
|||||||
Reference in New Issue
Block a user