Upload folder using huggingface_hub
Browse files
client/src/pages/TutorialTasks.tsx
CHANGED
|
@@ -816,10 +816,18 @@ const TutorialTasks: React.FC = () => {
|
|
| 816 |
});
|
| 817 |
|
| 818 |
if (response.status >= 200 && response.status < 300) {
|
| 819 |
-
const
|
| 820 |
-
console.log('Submission created successfully:',
|
| 821 |
-
|
| 822 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
withPreservedCardOffset(taskId, () => {
|
| 824 |
React.startTransition(() => {
|
| 825 |
setTranslationText({ ...translationText, [taskId]: '' });
|
|
@@ -896,7 +904,16 @@ const TutorialTasks: React.FC = () => {
|
|
| 896 |
const response = await api.delete(`/api/submissions/${submissionId}`);
|
| 897 |
|
| 898 |
if (response.status === 200) {
|
| 899 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 900 |
// Defer refetch to prevent UI jumping and preserve scroll around DOM updates
|
| 901 |
if (taskId) lockCardHeightById(taskId);
|
| 902 |
withPreservedCardOffset(taskId || '', () => {
|
|
|
|
| 816 |
});
|
| 817 |
|
| 818 |
if (response.status >= 200 && response.status < 300) {
|
| 819 |
+
const created = response.data;
|
| 820 |
+
console.log('Submission created successfully:', created);
|
| 821 |
+
|
| 822 |
+
// Optimistic append to avoid large reflow from full refetch
|
| 823 |
+
setUserSubmissions(prev => {
|
| 824 |
+
const current = prev[taskId] || [];
|
| 825 |
+
// Put newest first like server returns
|
| 826 |
+
const next = [{ ...created, isOwner: true }, ...current];
|
| 827 |
+
return { ...prev, [taskId]: next };
|
| 828 |
+
});
|
| 829 |
+
|
| 830 |
+
// Defer state updates and minimal refetch
|
| 831 |
withPreservedCardOffset(taskId, () => {
|
| 832 |
React.startTransition(() => {
|
| 833 |
setTranslationText({ ...translationText, [taskId]: '' });
|
|
|
|
| 904 |
const response = await api.delete(`/api/submissions/${submissionId}`);
|
| 905 |
|
| 906 |
if (response.status === 200) {
|
| 907 |
+
|
| 908 |
+
// Optimistically remove from local submissions to avoid large reflow
|
| 909 |
+
if (taskId) {
|
| 910 |
+
setUserSubmissions(prev => {
|
| 911 |
+
const list = prev[taskId] || [];
|
| 912 |
+
const next = list.filter(s => s._id !== submissionId);
|
| 913 |
+
return { ...prev, [taskId]: next };
|
| 914 |
+
});
|
| 915 |
+
}
|
| 916 |
+
|
| 917 |
// Defer refetch to prevent UI jumping and preserve scroll around DOM updates
|
| 918 |
if (taskId) lockCardHeightById(taskId);
|
| 919 |
withPreservedCardOffset(taskId || '', () => {
|