Skip to content

Commit

Permalink
check that chapter is available before access it in the local cache
Browse files Browse the repository at this point in the history
  • Loading branch information
GrakovNe committed Dec 15, 2024
1 parent 80cd394 commit 3f72ff7
Showing 1 changed file with 2 additions and 1 deletion.
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 3f72ff7

Please sign in to comment.