fix: ensure books display in biblical order (Old Testament → New Testament)
- 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 <noreply@anthropic.com>
This commit is contained in:
@@ -158,14 +158,14 @@ export default function BibleReaderNew({ initialVersion, initialBook, initialCha
|
|||||||
if (key === 'version') return initialVersion || null
|
if (key === 'version') return initialVersion || null
|
||||||
if (key === 'book') return initialBook || null
|
if (key === 'book') return initialBook || null
|
||||||
if (key === 'chapter') return initialChapter || 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
|
return null
|
||||||
},
|
},
|
||||||
has: (key: string) => {
|
has: (key: string) => {
|
||||||
if (key === 'version') return !!initialVersion
|
if (key === 'version') return !!initialVersion
|
||||||
if (key === 'book') return !!initialBook
|
if (key === 'book') return !!initialBook
|
||||||
if (key === 'chapter') return !!initialChapter
|
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
|
return false
|
||||||
},
|
},
|
||||||
toString: (): string => ''
|
toString: (): string => ''
|
||||||
|
|||||||
@@ -210,11 +210,13 @@ class OfflineStorage {
|
|||||||
|
|
||||||
async getBooksForVersion(versionId: string): Promise<BibleBook[]> {
|
async getBooksForVersion(versionId: string): Promise<BibleBook[]> {
|
||||||
await this.init()
|
await this.init()
|
||||||
return this.performTransaction('books', 'readonly', (store) => {
|
const books = await this.performTransaction('books', 'readonly', (store) => {
|
||||||
const booksStore = store as IDBObjectStore
|
const booksStore = store as IDBObjectStore
|
||||||
const index = booksStore.index('versionId')
|
const index = booksStore.index('versionId')
|
||||||
return index.getAll(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
|
// Download progress management
|
||||||
|
|||||||
Reference in New Issue
Block a user