Fix updating custom thumbnail images

pull/320/head
ElementalAlchemist 2 years ago committed by Mike Lang
parent 93535b0af7
commit 797a36eaab

@ -911,19 +911,23 @@ async function sendVideoData(newState, overrideChanges) {
loadPromiseResolve = resolve;
});
fileReader.addEventListener("loadend", (event) => {
loadPromiseResolve(event.target);
loadPromiseResolve();
});
fileReader.readAsArrayBuffer(fileHandle);
const fileLoadData = await loadPromise;
fileReader.readAsDataURL(fileHandle);
await loadPromise;
const fileLoadData = fileReader.result;
if (fileLoadData.error) {
submissionResponseElem.innerText = `An error (${fileLoadData.error.name}) occurred loading the custom thumbnail: ${fileLoadData.error.message}`;
submissionResponseElem.classList.value = ["submission-response-error"];
return;
}
const fileData = fileLoadData.result;
const fileBytes = new Uint8Array(fileData);
const fileBinaryString = String.fromCharCode(...fileBytes);
thumbnailImage = btoa(fileBinaryString);
if (fileLoadData.substring(0, 22) !== "data:image/png;base64,") {
submissionResponseElem.innerHTML =
"An error occurred converting the uploaded image to base64.";
submissionResponseElem.classList.value = ["submission-response-error"];
return;
}
thumbnailImage = fileLoadData.substring(22);
}
}

Loading…
Cancel
Save