diff --git a/src/pages/queryBuilder/textEditor/textEditorRow/NodeSelector.jsx b/src/pages/queryBuilder/textEditor/textEditorRow/NodeSelector.jsx index 02b8986f..e52f46f6 100644 --- a/src/pages/queryBuilder/textEditor/textEditorRow/NodeSelector.jsx +++ b/src/pages/queryBuilder/textEditor/textEditorRow/NodeSelector.jsx @@ -103,14 +103,13 @@ export default function NodeSelector({ if (includeCuries) { if (searchTerm.includes(':')) { // user is typing a specific curie newOptions.push({ name: searchTerm, ids: [searchTerm] }); - } else { - if (cancel) { - cancel.cancel(); - } - cancel = CancelToken.source(); - const curies = await fetchCuries(searchTerm, displayAlert, cancel.token); - newOptions.push(...curies); } + if (cancel) { + cancel.cancel(); + } + cancel = CancelToken.source(); + const curies = await fetchCuries(searchTerm, displayAlert, cancel.token); + newOptions.push(...curies); } toggleLoading(false); setOptions(newOptions); diff --git a/src/utils/fetchCuries.js b/src/utils/fetchCuries.js index 2033e873..e4c1990f 100644 --- a/src/utils/fetchCuries.js +++ b/src/utils/fetchCuries.js @@ -12,28 +12,10 @@ export default async function fetchCuries(entity, displayAlert, cancel) { if (!Array.isArray(response)) { return []; } - const curieResponse = response.map((node) => node.curie); - if (!curieResponse.length) { - return []; - } - - // Pass curies to nodeNormalizer to get category information and - // a better curie identifier - const normalizationResponse = await API.nodeNormalization.getNormalizedNodes({ curies: curieResponse }, cancel); - - if (normalizationResponse.status === 'error') { - displayAlert('error', - 'Failed to contact node normalizer to search curies. Please try again later.'); - return []; - } - // Sometimes the nodeNormalizer returns null responses - // so we use a filter to remove those - const newOptions = Object.values(normalizationResponse).filter((c) => c).map((c) => ({ - name: c.id.label || c.id.identifier, - categories: c.type, - ids: [c.id.identifier], + return response.map(({ curie, label, types }) => ({ + name: label, + categories: types, + ids: [curie], })); - - return newOptions; }