fix: isolate attachment submission state
This commit is contained in:
@@ -301,7 +301,8 @@ export function CodingChatPanel({
|
||||
]);
|
||||
|
||||
const handleAddFiles = useCallback((files: File[]) => {
|
||||
if (!draftKey) return;
|
||||
if (!draftKey
|
||||
|| (targetConversationId && submissionFlightsRef.current.has(targetConversationId))) return;
|
||||
const accepted: LocalComposerAttachment[] = [];
|
||||
const remaining = Math.max(0, CODING_ATTACHMENT_MAX_COUNT - localAttachments.length);
|
||||
let validationError = files.length > remaining
|
||||
@@ -335,10 +336,11 @@ export function CodingChatPanel({
|
||||
...current,
|
||||
[draftKey]: [...(current[draftKey] ?? []), ...accepted],
|
||||
}));
|
||||
}, [draftKey, localAttachments.length]);
|
||||
}, [draftKey, localAttachments.length, targetConversationId]);
|
||||
|
||||
const handleRemoveAttachment = useCallback((id: string) => {
|
||||
if (!draftKey) return;
|
||||
if (!draftKey
|
||||
|| (targetConversationId && submissionFlightsRef.current.has(targetConversationId))) return;
|
||||
setAttachmentsByDraftKey((current) => {
|
||||
const attachment = current[draftKey]?.find((item) => item.id === id);
|
||||
if (attachment) URL.revokeObjectURL(attachment.previewUrl);
|
||||
@@ -349,7 +351,12 @@ export function CodingChatPanel({
|
||||
});
|
||||
uploadedAttachmentsRef.current.delete(id);
|
||||
uploadFlightsRef.current.delete(id);
|
||||
}, [draftKey]);
|
||||
setSubmissionErrors((current) => {
|
||||
const next = { ...current };
|
||||
delete next[draftKey];
|
||||
return next;
|
||||
});
|
||||
}, [draftKey, targetConversationId]);
|
||||
|
||||
const prepareAttachments = useCallback(async (
|
||||
attachments: LocalComposerAttachment[],
|
||||
|
||||
Reference in New Issue
Block a user