Skip to content

Commit

Permalink
custom novel search fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelonion committed Jan 9, 2024
1 parent e3e3965 commit 7e5def3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ class MediaDetailsViewModel : ViewModel() {
val novelSources = NovelSources
val novelResponses = MutableLiveData<List<ShowResponse>>(null)
suspend fun searchNovels(query: String, i: Int) {
val source = novelSources[i]
val position = if (i >= novelSources.list.size) 0 else i
val source = novelSources[position]
tryWithSuspend(post = true) {
if (source != null) {
novelResponses.postValue(source.search(query))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ class NovelReadFragment : Fragment(),
headerAdapter.progress?.visibility = View.VISIBLE
lifecycleScope.launch(Dispatchers.IO) {
if (auto || query == "") model.autoSearchNovels(media)
//else model.searchNovels(query, source)
else model.autoSearchNovels(media) //testing
else model.searchNovels(query, source)
}
searching = true
if (save) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/ani/dantotsu/parsers/novel/NovelAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class DynamicNovelParser(extension: NovelExtension.Installed) : NovelParser() {

override suspend fun search(query: String): List<ShowResponse> {
val source = extension.sources.firstOrNull()
if (source is NovelInterface) {
return source.search(query, client)
return if (source is NovelInterface) {
source.search(query, client)
} else {
return emptyList()
emptyList()
}
}

Expand Down

0 comments on commit 7e5def3

Please sign in to comment.