Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ontologies displayed twice (DEV-1325) #832

Merged
merged 2 commits into from Sep 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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