Fix crash with empty EnumSet

This commit is contained in:
Koitharu
2023-07-24 16:57:24 +03:00
parent 345a878d83
commit 5ca22f1419
3 changed files with 11 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ import org.koitharu.kotatsu.core.util.AlphanumComparator
import org.koitharu.kotatsu.core.util.ext.MutableEventFlow
import org.koitharu.kotatsu.core.util.ext.call
import org.koitharu.kotatsu.core.util.ext.map
import org.koitharu.kotatsu.core.util.ext.toEnumSet
import org.koitharu.kotatsu.explore.data.MangaSourcesRepository
import org.koitharu.kotatsu.parsers.model.MangaSource
import org.koitharu.kotatsu.parsers.util.toTitleCase
@@ -122,7 +123,7 @@ class SourcesListViewModel @Inject constructor(
private suspend fun buildList() = withContext(Dispatchers.Default) {
val allSources = repository.allMangaSources
val enabledSources = repository.getEnabledSources()
val enabledSet = EnumSet.copyOf(enabledSources)
val enabledSet = enabledSources.toEnumSet()
val query = searchQuery
if (!query.isNullOrEmpty()) {
items.value = allSources.mapNotNull {