This commit is contained in:
choelzl 2022-02-23 20:57:23 +01:00
parent cb0a79d1e0
commit 617adace59
Signed by: sora
GPG Key ID: A362EA0491E2EEA0

View File

@ -89,7 +89,7 @@ $(async function () {
preloaded = false;
var loadedimages = {};
for (let i=0; i<emotes.length; i++) {
var image = new Image();
const image = new Image();
image.onload = function () {
loadcount++;
if (loadcount == loadtotal) preloaded = true;
@ -102,19 +102,16 @@ $(async function () {
const loadImagesTwitch = async(emotesId) => {
let loadcount = 0;
let loadtotal = emotesId.length;
var localPreloaded = false;
const promiseArray = [];
for (let i=0; i<emotesId.length; i++) {
var image = new Image();
image.onload = function () {
loadcount++;
if (loadcount == loadtotal) localPreloaded = true;
};
image.src = "https://static-cdn.jtvnw.net/emoticons/v2/" + emotesId[i] + "/default/dark/2.0";
img_map[emotesId[i]] = image;
promiseArray.push(new Promise(resolve => {
const image = new Image();
image.onload = () => resolve();
image.src = "https://static-cdn.jtvnw.net/emoticons/v2/" + emotesId[i] + "/default/dark/2.0";
img_map[emotesId[i]] = image;
}));
}
await waitFor(_ => localPreloaded === true);
await Promise.all(promiseArray);
return true;
}