Fix branch detection #143

This commit is contained in:
Koitharu
2022-04-17 09:58:52 +03:00
parent d61ba80bf6
commit 5fbae1256b

View File

@@ -191,7 +191,8 @@ class DetailsViewModel(
// find default branch // find default branch
val hist = historyRepository.getOne(manga) val hist = historyRepository.getOne(manga)
selectedBranch.value = if (hist != null) { selectedBranch.value = if (hist != null) {
manga.chapters?.find { it.id == hist.chapterId }?.branch val currentChapter = manga.chapters?.find { it.id == hist.chapterId }
if (currentChapter != null) currentChapter.branch else predictBranch(manga.chapters)
} else { } else {
predictBranch(manga.chapters) predictBranch(manga.chapters)
} }
@@ -203,6 +204,8 @@ class DetailsViewModel(
} else { } else {
localMangaRepository.findSavedManga(manga) localMangaRepository.findSavedManga(manga)
} }
}.onFailure { error ->
if (BuildConfig.DEBUG) error.printStackTrace()
}.getOrNull() }.getOrNull()
} }