To recreate: 1. Turn on all CoceProviders and IntranetCoce. 2. Set CoceHost to 'https://coce.bywatersolutions.com' 3. Do a search and notice that no Coce images load on the results page. 4. In intranet-tmpl/js/coce.js add a debug line inside the `$("[id^=coce-thumbnail]").each(function() {` loop. 5. Nothing happens! This div is being prematurely removed via intranet-tmpl/prog/js/pages/results.js I don't think it is safe to remove the Coce div's without first knowing that KOHA.coce is finished. In results.js: 102 $(window).load(function() { 103 verify_cover_images(); 104 }); Just using a window load is not good enough. We either need to not remove the div ( hiding it is safer ) or we need to use a callback, promise, or async/await.
There is a wait_for_images() callback used elsewhere, it seems like we need it here too.
Created attachment 160279 [details] [review] Bug 35647: Use callback when waiting for Coce to load 1. Turn on all CoceProviders and IntranetCoce. 2. Set CoceHost to 'https://coce.bywatersolutions.com' 3. Do a search and notice that no Coce images load on the results page. 4. Apply patch, clear browser cache and try again. 5. Images should load.
Created attachment 160280 [details] [review] Bug 35647: Use callback when waiting for Coce to load 1. Turn on all CoceProviders and IntranetCoce. 2. Set CoceHost to 'https://coce.bywatersolutions.com' 3. Do a search and notice that no Coce images load on the results page. 4. Apply patch, clear browser cache and try again. 5. Images should load. Signed-off-by: David Nind <david@davidnind.com>
If Coce is disabled you are going to wait 5 seconds, always!
Created attachment 161616 [details] [review] Bug 35647: (follow-up) Ensure Coce is on
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(); } Shouldnt you differentiate loaded is true and !loaded && counter_wait > 50 ? Now you always go the callback? $(window).load(function() { if ( PREF_IntranetCoce && PREF_CoceProviders ) { wait_for_images(verify_cover_images); } }); What about the other source of images? Amazon or whatever? Is that condition really correct?