Skip to content

Commit

Permalink
fixed autocompletion cache
Browse files Browse the repository at this point in the history
  • Loading branch information
litvinovg authored and chenejac committed Oct 28, 2024
1 parent b742982 commit 69d4cde
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,12 @@ var customForm = {
//Reset the URI of the input to one that says new uri required
//That will be overwritten if value selected from autocomplete
//We do this everytime the user types anything in the autocomplete box
let autocompleteType = customForm.acTypes[$(selectedObj).attr('acGroupName')];
customForm.initDefaultBlankURI(selectedObj);
if (request.term in customForm.acCache) {
let cacheKey = autocompleteType + ":" + request.term;
if (cacheKey in customForm.acCache) {
// console.log('found term in cache');
response(customForm.acCache[request.term]);
response(customForm.acCache[cacheKey]);
return;
}
// console.log('not getting term from cache');
Expand All @@ -318,7 +320,7 @@ var customForm = {
dataType: 'json',
data: {
term: request.term,
type: customForm.acTypes[$(selectedObj).attr('acGroupName')],
type: autocompleteType,
multipleTypes:(customForm.acMultipleTypes == undefined || customForm.acMultipleTypes == null)? null: customForm.acMultipleTypes
},
complete: function(xhr, status) {
Expand All @@ -333,7 +335,7 @@ var customForm = {
filteredResults = customForm.removeConceptSubclasses(filteredResults);
}

customForm.acCache[request.term] = filteredResults;
customForm.acCache[cacheKey] = filteredResults;
response(filteredResults);
}
});
Expand Down

0 comments on commit 69d4cde

Please sign in to comment.