From f2766690d8ab990932168949bda15995674a69c9 Mon Sep 17 00:00:00 2001 From: chrisala Date: Thu, 12 Dec 2024 16:25:33 +1100 Subject: [PATCH] Cache org name search results #3369 --- grails-app/assets/components/javascript/associated-orgs.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grails-app/assets/components/javascript/associated-orgs.js b/grails-app/assets/components/javascript/associated-orgs.js index e103b033d..4a0b80f76 100644 --- a/grails-app/assets/components/javascript/associated-orgs.js +++ b/grails-app/assets/components/javascript/associated-orgs.js @@ -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()) { @@ -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();