Spaces:
Sleeping
Sleeping
Update web/src/components/ChatArea.tsx
Browse files
web/src/components/ChatArea.tsx
CHANGED
|
@@ -50,7 +50,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from ".
|
|
| 50 |
import { SmartReview } from "./SmartReview";
|
| 51 |
import clareAvatar from "../assets/dfe44dab3ad8cd93953eac4a3e68bd1a5f999653.png";
|
| 52 |
|
| 53 |
-
//
|
| 54 |
import { useObjectUrlCache } from "../lib/useObjectUrlCache";
|
| 55 |
|
| 56 |
type ReviewEventType = "send_message" | "review_topic" | "review_all";
|
|
@@ -60,9 +60,8 @@ interface ChatAreaProps {
|
|
| 60 |
onSendMessage: (content: string) => void;
|
| 61 |
uploadedFiles: UploadedFile[];
|
| 62 |
onFileUpload: (files: File[]) => void;
|
|
|
|
| 63 |
|
| 64 |
-
// ✅ FIX: remove by File (NOT by index)
|
| 65 |
-
onRemoveFile: (file: File) => void;
|
| 66 |
|
| 67 |
onFileTypeChange: (index: number, type: FileType) => void;
|
| 68 |
memoryProgress: number;
|
|
@@ -594,11 +593,13 @@ export function ChatArea({
|
|
| 594 |
const thumbUrl = isImage ? getOrCreate(file) : null;
|
| 595 |
|
| 596 |
// ✅ FIX: uploaded remove by File; pending remove by File (not index)
|
|
|
|
| 597 |
const handleRemove = () => {
|
| 598 |
if (source === "uploaded") {
|
| 599 |
-
onRemoveFile(
|
| 600 |
} else {
|
| 601 |
-
|
|
|
|
| 602 |
}
|
| 603 |
};
|
| 604 |
|
|
@@ -1213,8 +1214,7 @@ export function ChatArea({
|
|
| 1213 |
<AlertDialogAction
|
| 1214 |
onClick={() => {
|
| 1215 |
if (fileToDelete !== null) {
|
| 1216 |
-
|
| 1217 |
-
if (f) onRemoveFile(f);
|
| 1218 |
setFileToDelete(null);
|
| 1219 |
}
|
| 1220 |
setShowDeleteDialog(false);
|
|
|
|
| 50 |
import { SmartReview } from "./SmartReview";
|
| 51 |
import clareAvatar from "../assets/dfe44dab3ad8cd93953eac4a3e68bd1a5f999653.png";
|
| 52 |
|
| 53 |
+
// NEW
|
| 54 |
import { useObjectUrlCache } from "../lib/useObjectUrlCache";
|
| 55 |
|
| 56 |
type ReviewEventType = "send_message" | "review_topic" | "review_all";
|
|
|
|
| 60 |
onSendMessage: (content: string) => void;
|
| 61 |
uploadedFiles: UploadedFile[];
|
| 62 |
onFileUpload: (files: File[]) => void;
|
| 63 |
+
onRemoveFile: (index: number) => void;
|
| 64 |
|
|
|
|
|
|
|
| 65 |
|
| 66 |
onFileTypeChange: (index: number, type: FileType) => void;
|
| 67 |
memoryProgress: number;
|
|
|
|
| 593 |
const thumbUrl = isImage ? getOrCreate(file) : null;
|
| 594 |
|
| 595 |
// ✅ FIX: uploaded remove by File; pending remove by File (not index)
|
| 596 |
+
// ✅ FIX: uploaded remove by INDEX (matches props); pending remove in local state
|
| 597 |
const handleRemove = () => {
|
| 598 |
if (source === "uploaded") {
|
| 599 |
+
onRemoveFile(index);
|
| 600 |
} else {
|
| 601 |
+
// pending: index is the map index of pendingFiles
|
| 602 |
+
setPendingFiles((prev) => prev.filter((_, i) => i !== index));
|
| 603 |
}
|
| 604 |
};
|
| 605 |
|
|
|
|
| 1214 |
<AlertDialogAction
|
| 1215 |
onClick={() => {
|
| 1216 |
if (fileToDelete !== null) {
|
| 1217 |
+
onRemoveFile(fileToDelete); // ✅ pass index
|
|
|
|
| 1218 |
setFileToDelete(null);
|
| 1219 |
}
|
| 1220 |
setShowDeleteDialog(false);
|