Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -857,24 +857,11 @@ const TutorialTasks: React.FC = () => {
|
|
| 857 |
return { ...prev, [taskId]: next };
|
| 858 |
});
|
| 859 |
|
| 860 |
-
// Defer state
|
| 861 |
-
// Measure grid height and set spacer before refetch to keep layout height constant
|
| 862 |
-
const gridEl = submissionsGridRefs.current[taskId];
|
| 863 |
-
const gridHeight = gridEl ? gridEl.getBoundingClientRect().height : 0;
|
| 864 |
-
if (gridHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: gridHeight }));
|
| 865 |
withPreservedCardOffset(taskId, () => {
|
| 866 |
React.startTransition(() => {
|
| 867 |
setTranslationText({ ...translationText, [taskId]: '' });
|
| 868 |
setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
|
| 869 |
-
// Narrow refetch: only this task's submissions
|
| 870 |
-
api.get(`/api/submissions/by-source/${taskId}`).then(r => {
|
| 871 |
-
const list = (r.data && r.data.submissions) || [];
|
| 872 |
-
setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
|
| 873 |
-
// Release spacer one frame after list update to avoid jump
|
| 874 |
-
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 875 |
-
}).catch(() => {
|
| 876 |
-
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 877 |
-
});
|
| 878 |
});
|
| 879 |
});
|
| 880 |
} else {
|
|
@@ -954,27 +941,10 @@ const TutorialTasks: React.FC = () => {
|
|
| 954 |
});
|
| 955 |
}
|
| 956 |
|
| 957 |
-
//
|
| 958 |
if (taskId) lockCardHeightById(taskId);
|
| 959 |
withPreservedCardOffset(taskId || '', () => {
|
| 960 |
-
React.startTransition(() => {
|
| 961 |
-
// Narrow refetch: only this task's submissions
|
| 962 |
-
if (taskId) {
|
| 963 |
-
const gridEl = submissionsGridRefs.current[taskId];
|
| 964 |
-
const gridHeight = gridEl ? gridEl.getBoundingClientRect().height : 0;
|
| 965 |
-
if (gridHeight > 0) setSpacerHeights(prev => ({ ...prev, [taskId]: gridHeight }));
|
| 966 |
-
api.get(`/api/submissions/by-source/${taskId}`).then(r => {
|
| 967 |
-
const list = (r.data && r.data.submissions) || [];
|
| 968 |
-
setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
|
| 969 |
-
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 970 |
-
}).catch(() => {
|
| 971 |
-
requestAnimationFrame(() => setSpacerHeights(prev => ({ ...prev, [taskId]: 0 })));
|
| 972 |
-
});
|
| 973 |
-
} else {
|
| 974 |
-
// Fallback
|
| 975 |
-
requestAnimationFrame(() => requestAnimationFrame(() => fetchUserSubmissions(tutorialTasks)));
|
| 976 |
-
}
|
| 977 |
-
});
|
| 978 |
});
|
| 979 |
} else {
|
| 980 |
|
|
|
|
| 857 |
return { ...prev, [taskId]: next };
|
| 858 |
});
|
| 859 |
|
| 860 |
+
// Defer only local state clears; skip refetch to avoid DOM churn
|
|
|
|
|
|
|
|
|
|
|
|
|
| 861 |
withPreservedCardOffset(taskId, () => {
|
| 862 |
React.startTransition(() => {
|
| 863 |
setTranslationText({ ...translationText, [taskId]: '' });
|
| 864 |
setSelectedGroups({ ...selectedGroups, [taskId]: 0 });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 865 |
});
|
| 866 |
});
|
| 867 |
} else {
|
|
|
|
| 941 |
});
|
| 942 |
}
|
| 943 |
|
| 944 |
+
// Skip refetch entirely to avoid layout churn; UI already updated optimistically
|
| 945 |
if (taskId) lockCardHeightById(taskId);
|
| 946 |
withPreservedCardOffset(taskId || '', () => {
|
| 947 |
+
React.startTransition(() => {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 948 |
});
|
| 949 |
} else {
|
| 950 |
|