feat: Improve EPUB loading status messaging and error handling

This commit is contained in:
JB
2025-10-13 12:58:57 -07:00
parent cab5221c46
commit 0f549a56e4
+26 -1
View File
@@ -811,8 +811,28 @@
return; return;
} }
setStatus('Fetching EPUB…');
book = window.ePub({
replacements: 'view',
requestCredentials: 'same-origin',
});
const preloadTimeout = setTimeout(() => {
setStatus('Still fetching EPUB… this may take a moment for large books.');
}, 4000);
try {
await book.open(epubUrl, 'epub');
} catch (error) {
console.error('Failed to fetch EPUB payload', error);
clearTimeout(preloadTimeout);
setStatus('Unable to fetch the EPUB asset for this job.');
return;
}
clearTimeout(preloadTimeout);
setStatus('Loading book…'); setStatus('Loading book…');
book = window.ePub(epubUrl, { openAs: 'epub' });
rendition = book.renderTo('reader-view', { rendition = book.renderTo('reader-view', {
flow: 'scrolled-doc', flow: 'scrolled-doc',
width: '100%', width: '100%',
@@ -821,6 +841,11 @@
allowScriptedContent: false, allowScriptedContent: false,
}); });
book.on('book:loadFailed', (error) => {
console.error('EPUB engine reported a load failure', error);
setStatus('EPUB content could not be loaded.');
});
registerRenditionHooks(); registerRenditionHooks();
let navigation = null; let navigation = null;