Skip to content

Commit 6b277ae

Browse files
authored
Fix agent duplication issue (#231)
Agents were not correctly de-duplicated by their uniqueness based on contact references due to a newer contact reference being displayed, while an older one was used to de-duplicate.
1 parent ce31f7d commit 6b277ae

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

src/app/components/metadata/agents/agents.component.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,22 @@ export class AgentsComponent implements OnDestroy, OnChanges {
134134
const pairs = Object.values(person.contact_references)
135135
.filter(isContact)
136136
.map(cr => withoutProps(cr, '_id', 'creation_date', 'note'))
137-
.map(cr =>
138-
Object.values(cr)
139-
.filter(_ => _)
140-
.join('-'),
141-
)
142-
.filter(pair => pair)
137+
.filter(pair => Object.values(pair).filter(_ => _).length > 0)
143138
.flat();
144139
for (const pair of pairs) {
145-
map.set(pair, person);
140+
const pairString = Object.values(pair).join('-');
141+
map.set(pairString, {
142+
...person,
143+
contact_references: {
144+
...person.contact_references,
145+
[this.entityId()]:
146+
person.contact_references[this.entityId()] ??
147+
new ContactReference({
148+
mail: pair.mail,
149+
phonenumber: pair.phonenumber,
150+
}),
151+
},
152+
});
146153
}
147154
}
148155
return Array.from(map.values());

0 commit comments

Comments
 (0)