Skip to content

Commit

Permalink
fixup! HAI-2065 Implement file upload component
Browse files Browse the repository at this point in the history
  • Loading branch information
markohaarni committed Nov 1, 2023
1 parent d351dda commit 6cc5390
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/common/components/fileUpload/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { AttachmentMetadata } from '../../types/attachment';

// Filter out duplicate files based on file name
export function removeDuplicateAttachments<T extends AttachmentMetadata>(
files: File[],
attachments: T[] | undefined,
addedFiles: File[],
existingAttachments: T[] | undefined,
): [File[], File[]] {
const duplicateFiles = files.filter(
(file) => attachments?.some((attachment) => attachment.fileName === file.name),
const duplicateFiles = addedFiles.filter(
(file) => existingAttachments?.some((attachment) => attachment.fileName === file.name),
);
const newFiles = files.filter(
(file) => attachments?.every((attachment) => attachment.fileName !== file.name),
const newFiles = addedFiles.filter(
(file) => existingAttachments?.every((attachment) => attachment.fileName !== file.name),
);
return [newFiles, duplicateFiles];
}

0 comments on commit 6cc5390

Please sign in to comment.