From fa72c992f443b3137f716955dc6c921cdc4e1775 Mon Sep 17 00:00:00 2001 From: Andrei Date: Tue, 30 Sep 2025 12:00:08 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20ensure=20books=20display=20in=20biblical?= =?UTF-8?q?=20order=20(Old=20Testament=20=E2=86=92=20New=20Testament)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Modified offline storage to sort books by orderNum after IndexedDB retrieval - Fixed book ordering issue where books appeared out of sequence - Books now consistently display: Genesis → Revelation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- app/[locale]/bible/reader.tsx | 4 ++-- lib/offline-storage.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/[locale]/bible/reader.tsx b/app/[locale]/bible/reader.tsx index 4022d3a..8140dd5 100644 --- a/app/[locale]/bible/reader.tsx +++ b/app/[locale]/bible/reader.tsx @@ -158,14 +158,14 @@ export default function BibleReaderNew({ initialVersion, initialBook, initialCha if (key === 'version') return initialVersion || null if (key === 'book') return initialBook || null if (key === 'chapter') return initialChapter || null - if (key === 'verse') return searchParams.get('verse') // Still get verse from URL query params + if (key === 'verse' && typeof window !== 'undefined') return searchParams.get('verse') // Only on client return null }, has: (key: string) => { if (key === 'version') return !!initialVersion if (key === 'book') return !!initialBook if (key === 'chapter') return !!initialChapter - if (key === 'verse') return searchParams.has('verse') + if (key === 'verse' && typeof window !== 'undefined') return searchParams.has('verse') // Only on client return false }, toString: (): string => '' diff --git a/lib/offline-storage.ts b/lib/offline-storage.ts index fcad4eb..8b455d8 100644 --- a/lib/offline-storage.ts +++ b/lib/offline-storage.ts @@ -210,11 +210,13 @@ class OfflineStorage { async getBooksForVersion(versionId: string): Promise { await this.init() - return this.performTransaction('books', 'readonly', (store) => { + const books = await this.performTransaction('books', 'readonly', (store) => { const booksStore = store as IDBObjectStore const index = booksStore.index('versionId') return index.getAll(versionId) }) + // Sort books by orderNum to maintain biblical order + return books.sort((a, b) => (a.orderNum || 0) - (b.orderNum || 0)) } // Download progress management