Skip to content

Commit

Permalink
#154 fix bug of multiplying evidences
Browse files Browse the repository at this point in the history
  • Loading branch information
JuliaSageder committed Feb 9, 2024
1 parent 723bd36 commit cfec3d3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/contexts/EvidenceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ export const EvidenceProvider: React.FC<EvidenceProviderProps> = ({
// if yes: overwrite with newer evidence version
// if not: push to to-update list
for (let i = 0; i < evidences.length; i++) {
for (let j = 0; j < updatedEvidenceList.length; j++) {
if (evidences[i].id === updatedEvidenceList[j].id) {
updatedEvidenceList[j] = evidences[i];
} else {
updatedEvidenceList.push(evidences[i]);
}
let checkForUpdate = updatedEvidenceList.findIndex(
(ev) => ev.id === evidences[i].id
);
if (checkForUpdate !== -1) {
updatedEvidenceList[checkForUpdate] = evidences[i];
} else {
updatedEvidenceList.push(evidences[i]);
}
}

/* // also check if some of the evidences have to be deleted completely
// duplicate code (see removeEvidencesWithoutReferences) because of asynchronous setState -> not finished when
for (let k = 0; k < updatedEvidenceList.length; k++) {
Expand Down

0 comments on commit cfec3d3

Please sign in to comment.