fix: confirm before generating audio peaks in browser, avoid lock-ups in Chrome

feat/type-attributes
Tomáš Mládek 2022-10-21 21:39:41 +02:00
parent a6c07c7810
commit 40381cf46d
1 changed files with 15 additions and 4 deletions

View File

@ -208,10 +208,21 @@
const peaks = await peaksReq.json();
wavesurfer.load(`${API_URL}/raw/${address}`, peaks.data);
} catch (e) {
console.warn(
`Failed to load peaks from server (${e}), falling back to client-side render...`
);
wavesurfer.load(`${API_URL}/raw/${address}`);
console.warn(`Failed to load peaks: ${e}`);
const entity = await fetchEntity(address);
console.log(entity.get("FILE_SIZE"));
if (
(entity.get("FILE_SIZE") || 0) < 20_000_000 ||
confirm(
"File is large (>20 MiB) and UpEnd failed to load waveform from server. Generating the waveform locally may slow down your browser. Do you wish to proceed anyway?"
)
) {
console.warn(
`Failed to load peaks, falling back to client-side render...`
);
wavesurfer.load(`${API_URL}/raw/${address}`);
}
}
});
</script>