refactor: check source loaded with launch instead of launchIO

This commit is contained in:
Cuong-Tran 2024-07-02 12:33:39 +07:00
parent 79568eb37b
commit a32316ddb4
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2
2 changed files with 18 additions and 16 deletions

View file

@ -133,7 +133,7 @@ open class BrowseSourceScreenModel(
init {
// KMK -->
screenModelScope.launchIO {
screenModelScope.launch {
var retry = 10
while (source !is CatalogueSource && retry-- > 0) {
// Sometime source is late to load, so we need to wait a bit
@ -141,23 +141,25 @@ open class BrowseSourceScreenModel(
source = sourceManager.getOrStub(sourceId)
}
val source = source
if (source !is CatalogueSource) return@launchIO
if (source !is CatalogueSource) return@launch
// KMK <--
mutableState.update {
var query: String? = null
var listing = it.listing
screenModelScope.launchIO {
mutableState.update {
var query: String? = null
var listing = it.listing
if (listing is Listing.Search) {
query = listing.query
listing = Listing.Search(query, source.getFilterList())
if (listing is Listing.Search) {
query = listing.query
listing = Listing.Search(query, source.getFilterList())
}
it.copy(
listing = listing,
filters = source.getFilterList(),
toolbarQuery = query,
)
}
it.copy(
listing = listing,
filters = source.getFilterList(),
toolbarQuery = query,
)
}
if (!basePreferences.incognitoMode().get()) {

View file

@ -84,7 +84,7 @@ open class SourceFeedScreenModel(
init {
// KMK -->
screenModelScope.launchIO {
screenModelScope.launch {
var retry = 10
while (source !is CatalogueSource && retry-- > 0) {
// Sometime source is late to load, so we need to wait a bit
@ -92,7 +92,7 @@ open class SourceFeedScreenModel(
source = sourceManager.getOrStub(sourceId)
}
val source = source
if (source !is CatalogueSource) return@launchIO
if (source !is CatalogueSource) return@launch
// KMK <--
setFilters(source.getFilterList())