Skip to content

Commit

Permalink
fix: Ontologies displayed twice (DEV-1325) (#832)
Browse files Browse the repository at this point in the history
* fix: Fixed bug by checking duplicates in Ontology Component

* fix: fixing auto imports and rename variables
  • Loading branch information
EricSommerhalder committed Sep 23, 2022
1 parent c15d87b commit ba35d6f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/app/project/ontology/ontology.component.ts
Expand Up @@ -382,7 +382,26 @@ export class OntologyComponent implements OnInit {
(ontologies: ReadOntology[]) => {
// update current list of project ontologies
ontologies[ontologies.findIndex(onto => onto.id === ontology.id)] = ontology;
this._cache.set('currentProjectOntologies', ontologies);
// avoid duplicates
const uniqueOntologies: ReadOntology[] = [];
const uniqueIds: String[] = [];
for (const onto of ontologies){
if (uniqueIds.indexOf(onto.id) !== -1){
let oldOntoIndex: number;
uniqueOntologies.forEach((o, index) => {
if (o.id === onto.id) {
oldOntoIndex = index;
}
});
if (Object.keys(onto.properties).length > Object.keys(uniqueOntologies[oldOntoIndex].properties).length){ // new onto has more props -> replace
uniqueOntologies[oldOntoIndex] = onto;
}
} else {
uniqueIds.push(onto.id);
uniqueOntologies.push(onto);
}
}
this._cache.set('currentProjectOntologies', uniqueOntologies);
},
() => {} // don't log error to rollbar if 'currentProjectOntologies' does not exist in the cache
);
Expand Down

0 comments on commit ba35d6f

Please sign in to comment.