Skip to content

Commit

Permalink
check that chapter is available before access it in the local cache (#81
Browse files Browse the repository at this point in the history
)

* check that chapter is available before access it in the local cache
  • Loading branch information
GrakovNe authored Dec 15, 2024
1 parent 80cd394 commit 6a42679
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId = "org.grakovne.lissen"
minSdk = 28
targetSdk = 35
versionCode = 50
versionName = "1.1.19"
versionCode = 51
versionName = "1.1.20"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ class LocalCacheRepository @Inject constructor(

val currentChapter = calculateChapterIndex(cachedBook, cachedPosition)

return when (cachedBook.chapters[currentChapter].available) {
return when (currentChapter in cachedBook.chapters.indices && cachedBook.chapters[currentChapter].available) {
true -> cachedBook

false ->
cachedBook
.copy(
Expand Down

0 comments on commit 6a42679

Please sign in to comment.