From 7f4bd35a856bb7714e71efa5e6c0a7788046e436 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Jan 2022 12:29:11 +0100 Subject: [PATCH] Bug 29803: Do not wait for the images more than 5 seconds In case of the previous bug, the page was calling the callback function every 100ms, endlessly. We should add a test to prevent future similar problem. Test plan: Remove the previous patch "Prevent local cover image to be hidden if Coce is enabled" Recreate the test plan => You should see the local image displayed after 5 seconds, and a log in the JS console Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens Signed-off-by: Fridolin Somers --- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index 70df935b51..f6dc6014a2 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1561,9 +1561,11 @@ }); } /* /verify_images */ + let counter_wait = 0; function wait_for_images(cb){ var loaded = 1; + counter_wait++; [% IF GoogleJackets %] if ( loaded ) { @@ -1583,9 +1585,12 @@ } [% END %] - if (!loaded) { + if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds window.setTimeout(function(){wait_for_images(cb);}, 100); } else { + if (counter_wait >= 50 ) { + console.log("Could not retrieve the images") + } cb(); } } -- 2.39.5