Skip to content

Commit

Permalink
Cache org name search results #3369
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed Dec 12, 2024
1 parent 9b80989 commit f276669
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions grails-app/assets/components/javascript/associated-orgs.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ ko.components.register('associated-orgs', {

var previousOrganisationId = null;
var organisationName = null;
var queryInProgress = false;
var self = this;
function setLabel() {
if (organisationName && organisationName != self.name()) {
Expand All @@ -70,12 +71,13 @@ ko.components.register('associated-orgs', {
}
}
function updateLabel() {
if (self.organisationId() && self.organisationId() != previousOrganisationId) {

if (!queryInProgress && self.organisationId() && self.organisationId() != previousOrganisationId) {
queryInProgress = true;
findMatchingOrganisation(self.organisationId(), function(matchingOrg) {
previousOrganisationId = self.organisationId();
organisationName = matchingOrg && matchingOrg._source ? matchingOrg._source.name : null;
setLabel();
queryInProgress = false;
});
}
setLabel();
Expand Down

0 comments on commit f276669

Please sign in to comment.