From 43cde382b8092d3a171e896d9426b16317d094b9 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 --- 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 52a7cec016d..190bcdf4025 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1543,9 +1543,11 @@ }); } /* /verify_images */ + let counter_wait = 0; function wait_for_images(cb){ var loaded = 1; + counter_wait++; [% IF GoogleJackets %] if ( loaded ) { @@ -1565,9 +1567,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.25.1