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