mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 05:22:02 +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,23 +566,31 @@ const useSelect = <T,>(
|
||||
setSize(size + 1);
|
||||
};
|
||||
|
||||
let formattedSuccessRawData: SuccessApiResponse<T[]> | undefined = undefined;
|
||||
let formattedErrorRawData: ErrorApiResponse | undefined = undefined;
|
||||
|
||||
const latestPagesIndex = pages?.length ? pages.length - 1 : 0;
|
||||
|
||||
if (isResponseSuccess(pages?.[latestPagesIndex])) {
|
||||
formattedSuccessRawData = {
|
||||
...pages?.[latestPagesIndex],
|
||||
data:
|
||||
pages?.flatMap((page) => (isResponseSuccess(page) ? page.data : [])) ??
|
||||
[],
|
||||
};
|
||||
}
|
||||
const { formattedSuccessRawData, formattedErrorRawData } = useMemo(() => {
|
||||
let successData: SuccessApiResponse<T[]> | undefined = undefined;
|
||||
let errorData: ErrorApiResponse | undefined = undefined;
|
||||
|
||||
if (isResponseError(pages?.[latestPagesIndex])) {
|
||||
formattedErrorRawData = pages?.[latestPagesIndex];
|
||||
}
|
||||
if (isResponseSuccess(pages?.[latestPagesIndex])) {
|
||||
successData = {
|
||||
...pages![latestPagesIndex],
|
||||
data:
|
||||
pages?.flatMap((page) =>
|
||||
isResponseSuccess(page) ? page.data : []
|
||||
) ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
if (isResponseError(pages?.[latestPagesIndex])) {
|
||||
errorData = pages![latestPagesIndex];
|
||||
}
|
||||
|
||||
return {
|
||||
formattedSuccessRawData: successData,
|
||||
formattedErrorRawData: errorData,
|
||||
};
|
||||
}, [pages, latestPagesIndex]);
|
||||
|
||||
return {
|
||||
inputValue,
|
||||
|
||||
@@ -974,9 +974,17 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (next[item.id] !== item) {
|
||||
next[item.id] = item;
|
||||
changed = true;
|
||||
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;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user