Skip to content

Commit

Permalink
Simplify new document event duplicate check
Browse files Browse the repository at this point in the history
  • Loading branch information
cskrov committed Oct 1, 2024
1 parent 4080e9e commit 864a057
Showing 1 changed file with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,12 @@ export const handleDocumentsAddedEvent = (oppgaveId: string, userId: string) =>
}

for (const document of event.documents) {
if (
!draft.some(
(d) =>
d.id === document.id ||
(d.type === DocumentTypeEnum.JOURNALFOERT &&
d.type === document.type &&
d.parentId === document.parentId &&
d.journalfoertDokumentReference.journalpostId ===
document.journalfoertDokumentReference.journalpostId &&
d.journalfoertDokumentReference.dokumentInfoId ===
document.journalfoertDokumentReference.dokumentInfoId),
)
) {
if (!draft.some((d) => d.id === document.id)) {
draft.push(document);
}
}

return draft.sort((a, b) => {
return draft.toSorted((a, b) => {
if (a.type === DocumentTypeEnum.JOURNALFOERT) {
if (b.type === DocumentTypeEnum.JOURNALFOERT) {
return b.journalfoertDokumentReference.sortKey.localeCompare(a.journalfoertDokumentReference.sortKey);
Expand Down

0 comments on commit 864a057

Please sign in to comment.