From dfa43a1a8061dfa8e8e83e5e76ea188975632b44 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 --- 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 c226da6dd0..6dc116c0b9 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1537,9 +1537,11 @@ }); } /* /verify_images */ + let counter_wait = 0; function wait_for_images(cb){ var loaded = 1; + counter_wait++; [% IF GoogleJackets %] if ( loaded ) { @@ -1559,9 +1561,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.30.2