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 <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
Jonathan Druart 2022-01-10 12:29:11 +01:00 committed by Kyle Hall
parent c7d350b510
commit 140f8e032b
1 changed files with 6 additions and 1 deletions

View File

@ -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();
}
}