Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -858,15 +858,23 @@ const TutorialTasks: React.FC = () => {
|
|
| 858 |
});
|
| 859 |
|
| 860 |
// Defer state updates and minimal refetch
|
|
|
|
|
|
|
|
|
|
|
|
|
| 861 |
withPreservedCardOffset(taskId, () => {
|
| 862 |
React.startTransition(() => {
|
| 863 |
-
|
| 864 |
-
|
| 865 |
// Narrow refetch: only this task's submissions
|
| 866 |
api.get(`/api/submissions/by-source/${taskId}`).then(r => {
|
| 867 |
const list = (r.data && r.data.submissions) || [];
|
| 868 |
setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
|
| 869 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 870 |
});
|
| 871 |
});
|
| 872 |
} else {
|
|
@@ -952,10 +960,16 @@ const TutorialTasks: React.FC = () => {
|
|
| 952 |
React.startTransition(() => {
|
| 953 |
// Narrow refetch: only this task's submissions
|
| 954 |
if (taskId) {
|
|
|
|
|
|
|
|
|
|
| 955 |
api.get(`/api/submissions/by-source/${taskId}`).then(r => {
|
| 956 |
const list = (r.data && r.data.submissions) || [];
|
| 957 |
setUserSubmissions(prev => ({ ...prev, [taskId]: list }));
|
| 958 |
-
|
|
|
|
|
|
|
|
|
|
| 959 |
} else {
|
| 960 |
// Fallback
|
| 961 |
requestAnimationFrame(() => requestAnimationFrame(() => fetchUserSubmissions(tutorialTasks)));
|
|
|
|
| 858 |
});
|
| 859 |
|
| 860 |
// Defer state updates and minimal refetch
|
| 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 {
|
|
|
|
| 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)));
|