Try re-downloading chat images 5x with 0.5s delay before giving up
This commit is contained in:
parent
23f023837b
commit
5f1e917819
@ -43,6 +43,7 @@
|
|||||||
src="/content/images/{{.LocalFilename}}"
|
src="/content/images/{{.LocalFilename}}"
|
||||||
width="{{.Width}}" height="{{.Height}}"
|
width="{{.Width}}" height="{{.Height}}"
|
||||||
onclick="image_carousel.querySelector('img').src = this.src; image_carousel.showModal();"
|
onclick="image_carousel.querySelector('img').src = this.src; image_carousel.showModal();"
|
||||||
|
onerror="img_load_err(event, this)"
|
||||||
>
|
>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{range .Videos}}
|
{{range .Videos}}
|
||||||
@ -371,6 +372,19 @@
|
|||||||
emoji_popup.close();
|
emoji_popup.close();
|
||||||
emoji_popup.innerHTML = ""; // remove the picker
|
emoji_popup.innerHTML = ""; // remove the picker
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Callback function: If a chat image hasn't been downloaded, wait 500ms and try again
|
||||||
|
function img_load_err(err_event, img) {
|
||||||
|
// TODO: if (isHTTP404(e)) {...}
|
||||||
|
console.log(img);
|
||||||
|
console.log(err_event);
|
||||||
|
var retries = parseInt(img.getAttribute("data-retries") ?? 0);
|
||||||
|
if (retries < 5) {
|
||||||
|
img.setAttribute("data-retries", retries + 1);
|
||||||
|
setTimeout(() => {img.src = img.src;}, 500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user