Debug books: show visible status at each load stage, bump SW to v7
Each step in loadBookList now updates the visible UI so the exact failure point is obvious without opening DevTools. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
dcef4736e6
commit
b0ce463cca
2 changed files with 6 additions and 8 deletions
|
|
@ -2608,19 +2608,18 @@ async function loadBookList() {
|
|||
if (!IS_AUTHENTICATED) return;
|
||||
const listEl = $('book-list');
|
||||
if (!listEl) return;
|
||||
listEl.innerHTML = '<p class="muted">Loading…</p>';
|
||||
listEl.innerHTML = '<p class="muted">Loading books…</p>';
|
||||
|
||||
try {
|
||||
listEl.innerHTML = '<p class="muted">Fetching book list from server…</p>';
|
||||
const res = await fetch('/books/', {cache: 'no-store'});
|
||||
if (!res.ok) {
|
||||
console.error('loadBookList: server returned', res.status);
|
||||
listEl.innerHTML = `<p class="muted">Server error ${res.status} loading books.</p>`;
|
||||
return;
|
||||
}
|
||||
const books = await res.json();
|
||||
if (!Array.isArray(books)) {
|
||||
console.error('loadBookList: unexpected response', books);
|
||||
listEl.innerHTML = `<p class="muted">Unexpected response from server.</p>`;
|
||||
listEl.innerHTML = `<p class="muted">Unexpected response from server (not an array).</p>`;
|
||||
return;
|
||||
}
|
||||
if (!books.length) {
|
||||
|
|
@ -2628,11 +2627,12 @@ async function loadBookList() {
|
|||
return;
|
||||
}
|
||||
|
||||
listEl.innerHTML = `<p class="muted">Found ${books.length} book(s) on server. Decrypting…</p>`;
|
||||
|
||||
let key;
|
||||
try {
|
||||
key = await getOrCreateEncKey();
|
||||
} catch (e) {
|
||||
console.error('loadBookList: getOrCreateEncKey failed', e);
|
||||
listEl.innerHTML = `<p class="muted">Encryption not available: ${e.message}. Make sure you are on HTTPS.</p>`;
|
||||
return;
|
||||
}
|
||||
|
|
@ -2645,14 +2645,12 @@ async function loadBookList() {
|
|||
bookMetaCache[b.id] = {title: meta.title || '?', author: meta.author || '', type: meta.type || 'epub'};
|
||||
decrypted.push({id: b.id, title: meta.title || '?', author: meta.author || '', type: meta.type || 'epub', scroll_fraction: b.scroll_fraction, uploaded_at: b.uploaded_at, keyOk: true});
|
||||
} catch (e) {
|
||||
console.warn(`loadBookList: could not decrypt book #${b.id}:`, e.message);
|
||||
bookMetaCache[b.id] = {title: `Book #${b.id}`, author: '', type: 'epub'};
|
||||
decrypted.push({id: b.id, title: `Book #${b.id}`, author: '', type: 'epub', scroll_fraction: b.scroll_fraction, uploaded_at: b.uploaded_at, keyOk: false});
|
||||
}
|
||||
}
|
||||
renderBookList(decrypted);
|
||||
} catch (e) {
|
||||
console.error('loadBookList error:', e);
|
||||
if (listEl) listEl.innerHTML = `<p class="muted">Error loading books: ${e.message}</p>`;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
* diora service worker — caches the app shell for offline use.
|
||||
*/
|
||||
|
||||
const CACHE = 'diora-v6';
|
||||
const CACHE = 'diora-v7';
|
||||
const PODCAST_CACHE = 'diora-podcast-v1';
|
||||
const SHELL = [
|
||||
'/static/css/app.css',
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue