Update usages

This commit is contained in:
Jobobby04 2023-10-01 15:56:07 -04:00
parent 68fdd471ac
commit 32a938e6d4
4 changed files with 12 additions and 16 deletions

View File

@ -26,9 +26,7 @@ import kotlinx.coroutines.flow.receiveAsFlow
import kotlinx.coroutines.flow.update import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json import kotlinx.serialization.json.Json
import tachiyomi.core.util.lang.awaitSingle
import tachiyomi.core.util.lang.launchIO import tachiyomi.core.util.lang.launchIO
import tachiyomi.core.util.lang.launchNonCancellable import tachiyomi.core.util.lang.launchNonCancellable
import tachiyomi.core.util.lang.withIOContext import tachiyomi.core.util.lang.withIOContext
@ -224,14 +222,14 @@ open class FeedScreenModel(
if (itemUI.source != null) { if (itemUI.source != null) {
withContext(coroutineDispatcher) { withContext(coroutineDispatcher) {
if (itemUI.savedSearch == null) { if (itemUI.savedSearch == null) {
itemUI.source.fetchLatestUpdates(1) itemUI.source.getLatestUpdates(1)
} else { } else {
itemUI.source.fetchSearchManga( itemUI.source.getSearchManga(
1, 1,
itemUI.savedSearch.query.orEmpty(), itemUI.savedSearch.query.orEmpty(),
getFilterList(itemUI.savedSearch, itemUI.source), getFilterList(itemUI.savedSearch, itemUI.source),
) )
}.awaitSingle() }
}.mangas }.mangas
} else { } else {
emptyList() emptyList()

View File

@ -154,14 +154,14 @@ open class SourceFeedScreenModel(
val page = try { val page = try {
withContext(coroutineDispatcher) { withContext(coroutineDispatcher) {
when (sourceFeed) { when (sourceFeed) {
is SourceFeedUI.Browse -> source.fetchPopularManga(1) is SourceFeedUI.Browse -> source.getPopularManga(1)
is SourceFeedUI.Latest -> source.fetchLatestUpdates(1) is SourceFeedUI.Latest -> source.getLatestUpdates(1)
is SourceFeedUI.SourceSavedSearch -> source.fetchSearchManga( is SourceFeedUI.SourceSavedSearch -> source.getSearchManga(
page = 1, page = 1,
query = sourceFeed.savedSearch.query.orEmpty(), query = sourceFeed.savedSearch.query.orEmpty(),
filters = getFilterList(sourceFeed.savedSearch, source), filters = getFilterList(sourceFeed.savedSearch, source),
) )
}.awaitSingle() }
}.mangas }.mangas
} catch (e: Exception) { } catch (e: Exception) {
emptyList() emptyList()

View File

@ -8,7 +8,6 @@ import info.debatty.java.stringsimilarity.NormalizedLevenshtein
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async import kotlinx.coroutines.async
import kotlinx.coroutines.supervisorScope import kotlinx.coroutines.supervisorScope
import tachiyomi.core.util.lang.awaitSingle
import tachiyomi.domain.manga.model.Manga import tachiyomi.domain.manga.model.Manga
import java.util.Locale import java.util.Locale
@ -31,7 +30,7 @@ class SmartSearchEngine(
query query
} }
val searchResults = source.fetchSearchManga(1, builtQuery, FilterList()).awaitSingle() val searchResults = source.getSearchManga(1, builtQuery, FilterList())
searchResults.mangas.map { searchResults.mangas.map {
val cleanedMangaTitle = cleanSmartSearchTitle(it.originalTitle) val cleanedMangaTitle = cleanSmartSearchTitle(it.originalTitle)
@ -54,7 +53,7 @@ class SmartSearchEngine(
} else { } else {
title title
} }
val searchResults = source.fetchSearchManga(1, searchQuery, FilterList()).awaitSingle() val searchResults = source.getSearchManga(1, searchQuery, FilterList())
if (searchResults.mangas.size == 1) { if (searchResults.mangas.size == 1) {
return@supervisorScope listOf(SearchEntry(searchResults.mangas.first(), 0.0)) return@supervisorScope listOf(SearchEntry(searchResults.mangas.first(), 0.0))

View File

@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.source.model.MangasPage
import eu.kanade.tachiyomi.source.model.MetadataMangasPage import eu.kanade.tachiyomi.source.model.MetadataMangasPage
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
import exh.metadata.metadata.RaisedSearchMetadata import exh.metadata.metadata.RaisedSearchMetadata
import tachiyomi.core.util.lang.awaitSingle
abstract class EHentaiPagingSource(override val source: CatalogueSource) : SourcePagingSource(source) { abstract class EHentaiPagingSource(override val source: CatalogueSource) : SourcePagingSource(source) {
@ -28,18 +27,18 @@ abstract class EHentaiPagingSource(override val source: CatalogueSource) : Sourc
class EHentaiSearchPagingSource(source: CatalogueSource, val query: String, val filters: FilterList) : EHentaiPagingSource(source) { class EHentaiSearchPagingSource(source: CatalogueSource, val query: String, val filters: FilterList) : EHentaiPagingSource(source) {
override suspend fun requestNextPage(currentPage: Int): MangasPage { override suspend fun requestNextPage(currentPage: Int): MangasPage {
return source.fetchSearchManga(currentPage, query, filters).awaitSingle() return source.getSearchManga(currentPage, query, filters)
} }
} }
class EHentaiPopularPagingSource(source: CatalogueSource) : EHentaiPagingSource(source) { class EHentaiPopularPagingSource(source: CatalogueSource) : EHentaiPagingSource(source) {
override suspend fun requestNextPage(currentPage: Int): MangasPage { override suspend fun requestNextPage(currentPage: Int): MangasPage {
return source.fetchPopularManga(currentPage).awaitSingle() return source.getPopularManga(currentPage)
} }
} }
class EHentaiLatestPagingSource(source: CatalogueSource) : EHentaiPagingSource(source) { class EHentaiLatestPagingSource(source: CatalogueSource) : EHentaiPagingSource(source) {
override suspend fun requestNextPage(currentPage: Int): MangasPage { override suspend fun requestNextPage(currentPage: Int): MangasPage {
return source.fetchLatestUpdates(currentPage).awaitSingle() return source.getLatestUpdates(currentPage)
} }
} }