From 3f72ff737e2a7c716389877e10e70a195bcb2abe Mon Sep 17 00:00:00 2001 From: grakovne Date: Sun, 15 Dec 2024 14:11:35 +0100 Subject: [PATCH] check that chapter is available before access it in the local cache --- .../org/grakovne/lissen/content/cache/LocalCacheRepository.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/grakovne/lissen/content/cache/LocalCacheRepository.kt b/app/src/main/java/org/grakovne/lissen/content/cache/LocalCacheRepository.kt index ddd5fe48..90494b69 100644 --- a/app/src/main/java/org/grakovne/lissen/content/cache/LocalCacheRepository.kt +++ b/app/src/main/java/org/grakovne/lissen/content/cache/LocalCacheRepository.kt @@ -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(