Merge branch 'fix/recording' into 'development'

[FIX/FE] Recording

See merge request mbugroup/lti-web-client!369
This commit is contained in:
Rivaldi A N S
2026-04-07 04:55:57 +00:00
2 changed files with 33 additions and 17 deletions
+22 -14
View File
@@ -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;
}
}
});