fix a weird rendering issue which was triggered by load events fireing after the timeout was already in action

This commit is contained in:
Mario
2025-07-29 09:28:00 +00:00
parent e79a70d2b1
commit ecc94cdecd
2 changed files with 8 additions and 1 deletions

View File

@@ -70,7 +70,7 @@ require_once('include/security.php');
define('PLATFORM_NAME', 'hubzilla');
define('STD_VERSION', '10.5.2');
define('STD_VERSION', '10.5.3');
define('ZOT_REVISION', '6.0');
define('DB_UPDATE_VERSION', 1263);

View File

@@ -971,6 +971,7 @@ function imagesLoaded(elements, callback) {
let loadedCount = 0;
let totalImages = 0;
let timeoutId;
let timedOut = false;
const timeout = 10000;
const processed = new Set(); // Use a Set for efficient lookup
@@ -982,6 +983,10 @@ function imagesLoaded(elements, callback) {
}
function checkComplete(src) {
// If preloading timed out make sure to not call the callback again
// in case a load event listener fires later.
if (timedOut) return;
// Skip processing if image has already been processed
if (processed.has(src)) return;
@@ -1029,7 +1034,9 @@ function imagesLoaded(elements, callback) {
// Set timeout for the loading process
timeoutId = setTimeout(() => {
console.warn(`Image loading timed out after ${timeout}ms`);
document.getElementById('image_counter').innerText = '';
callback(false);
timedOut = true;
}, timeout);
// Iterate through images to add load and error event listeners