Skip to content

Commit

Permalink
Hangs when selecting book with no chapter 1 (#772)
Browse files Browse the repository at this point in the history
* Hangs when selecting book with no chapter 1

* Simplify code.

* added break for clarification
  • Loading branch information
davidmoore1 authored and aidanpscott committed Jan 27, 2025
1 parent 7f1f973 commit 159ba91
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/components/BookSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ The navbar component.
let count = Object.keys(books.find((x) => x.bookCode === book).versesByChapters).length;
return count;
}
function firstChapter(book) {
let first = Object.keys(books.find((x) => x.bookCode === book).versesByChapters)[0];
return first;
}
function getVerseCount(chapter, chapters) {
if (!chapter || chapter === 'i' || !chapters || Object.keys(chapters).length === 0) {
return 0;
Expand Down Expand Up @@ -78,8 +81,9 @@ The navbar component.
if (count === 0) {
$nextRef.chapter = 'i';
await completeNavigation();
break;
}
$nextRef.chapter = '1';
$nextRef.chapter = firstChapter($nextRef.book);
if (count === 1) {
await completeNavigation();
}
Expand Down

0 comments on commit 159ba91

Please sign in to comment.