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

Loading…
Cancel
Save