mirror of
https://github.com/denizsafak/abogen.git
synced 2026-07-18 21:50:28 +02:00
feat: Improve EPUB loading status messaging and error handling
This commit is contained in:
@@ -811,8 +811,28 @@
|
||||
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…');
|
||||
book = window.ePub(epubUrl, { openAs: 'epub' });
|
||||
|
||||
rendition = book.renderTo('reader-view', {
|
||||
flow: 'scrolled-doc',
|
||||
width: '100%',
|
||||
@@ -821,6 +841,11 @@
|
||||
allowScriptedContent: false,
|
||||
});
|
||||
|
||||
book.on('book:loadFailed', (error) => {
|
||||
console.error('EPUB engine reported a load failure', error);
|
||||
setStatus('EPUB content could not be loaded.');
|
||||
});
|
||||
|
||||
registerRenditionHooks();
|
||||
|
||||
let navigation = null;
|
||||
|
||||
Reference in New Issue
Block a user