Enonic version: 7.8.2
macOS: 12.0.1
Content Studio: 4.0.2
I have a CustomSelector that gets results from an external API. Results are returning correct, with no duplicate IDs (we’ve added safeguards for this in the code). With each new tap and depending on how fast I’m typing (filling in or removing characters), it seems that the CustomSelector doesn’t understand the exchange of results and sometimes returns a duplicate ID error.
Please, check my record:
Here is a part of my code that creates the service return:
GetSnowstormUseCase.prototype.execute = function execute (text, conceptRefset) {
const self = this
if (text) {
const response = self.Snowstorm.queryInSnowstormAPIRefset(text, conceptRefset)
const items = self.Collections.forceArray(response && response.items)
const hits = []
items.forEach(item => {
if (item.concept) {
if (!hits.some(el => el.id === item.concept.conceptId)) {
if (item.concept && item.concept.fsn && item.concept.pt) {
hits.push({
id: item.concept.conceptId,
description: `FSN Term: ${item.concept.fsn.term}; SCTID: ${item.concept.conceptId}`,
displayName: item.concept.pt.term
})
}
}
}
})
return {
hits: hits,
total: hits.length,
count: hits.length
}
} else {
return {
hits: [],
total: 0,
count: 0
}
}
}
Let me know if I can help with any more information.