Skip to content

Commit 1ca2587

Browse files
committed
added retryCount/updateRetryCount to eds_sessionStorage to persist after page reloads
1 parent 05b5a83 commit 1ca2587

4 files changed

Lines changed: 20 additions & 8 deletions

File tree

Koha/Plugin/EDS.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ our $MAJOR_VERSION = "24.11";
3434
our $SUB_VERSION = "002";
3535
our $VERSION = $MAJOR_VERSION . "" . $SUB_VERSION;
3636
our $SHA_ADD = "https://widgets.ebscohost.com/prod/api/koha/sha/1711.json";
37-
our $DATE_UPDATE = '2025-05-12';
37+
our $DATE_UPDATE = '2025-05-13';
3838
######################################################
3939

4040
## Here is our metadata, some keys are required, some are optional

Koha/Plugin/EDS/admin/release_notes.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
<kohaplugin>
44
<latestversion>24.11.002</latestversion>
55
<download>https://github.com/ebsco/edsapi-koha-plugin</download>
6-
<lastupdated>2025/05/12</lastupdated>
6+
<lastupdated>2025/05/13</lastupdated>
77
<releasenotes>
8-
<release version="24.11.002" date="2025/05/12">
8+
<release version="24.11.002" date="2025/05/13">
99
<note id="1" author="omuzzy@ebsco.com">minor fixes for Koha 24.11</note>
1010
<note id="2" author="omuzzy@ebsco.com">fix for EDS Autocomplete functionality</note>
1111
</release>

Koha/Plugin/EDS/js/EDSScript.tt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,8 +1294,17 @@ function DateHandleKeyPress(e, searchBox) {
12941294
}
12951295
}
12961296

1297-
//retry count added for fetchCredentials/EDSAutoComp
1298-
var retryCount = 0;
1297+
//retry counter added for fetchCredentials/EDSAutoComp
1298+
// Update retryCount in sessionStorage whenever it changes
1299+
function updateRetryCount(value) {
1300+
let retryCount = value;
1301+
eds_sessionStorage.set("retryCount", retryCount);
1302+
}
1303+
1304+
if (!(eds_sessionStorage.get("retryCount"))) {
1305+
updateRetryCount(0); // Initialize retryCount if not already set
1306+
}
1307+
12991308

13001309
//function to fetch credentials before running EDSAutoComp
13011310
async function fetchCredentials() {
@@ -1325,7 +1334,7 @@ async function fetchCredentials() {
13251334
"autoComp_expiry",
13261335
Math.round(Date.now() / 1000) + parseInt(creds.AuthTimeout) - 30
13271336
);
1328-
retryCount = 0; // Reset retry count on successful fetch
1337+
updateRetryCount(0); // Reset retry count on successful fetch
13291338
return creds; // Return the new credentials
13301339
} else {
13311340
return creds; // Return existing credentials
@@ -1437,8 +1446,8 @@ async function EDSAutoComp() {
14371446
if (edsConfig.logerrors == "yes") {
14381447
console.log("Error in autocomplete response:", data.error);
14391448
}
1440-
if (data.error && retryCount < 2) {
1441-
retryCount++;
1449+
if (data.error && (eds_sessionStorage.get("retryCount") < 2)) {
1450+
updateRetryCount((eds_sessionStorage.get("retryCount")) + 1); // Increment retry count
14421451
if (edsConfig.logerrors == "yes") {
14431452
console.log("Removing autoComp and autoComp_expiry due to data.error...");
14441453
console.log("Retrying fetchCredentials...");
@@ -1451,6 +1460,9 @@ async function EDSAutoComp() {
14511460
console.log("Retrying autocomplete request...");
14521461
}
14531462
jQuery("#translControl1").trigger("input");
1463+
if (edsConfig.logerrors == "yes") {
1464+
console.log("Autocomplete retriggered after refetching credentials...");
1465+
}
14541466
return;
14551467
} else {
14561468
eds_sessionStorage.remove("autoComp");

eds_plugin_24.11002.kpz

127 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)