Fix default category showing up in edit manga categories list
Also remove some usages of runBlocking
This commit is contained in:
parent
3c2e237d63
commit
3bc6b1e202
@ -8,13 +8,13 @@ import eu.kanade.tachiyomi.R
|
||||
|
||||
val Category.visualName: String
|
||||
@Composable
|
||||
get() = when (id) {
|
||||
Category.UNCATEGORIZED_ID -> stringResource(id = R.string.label_default)
|
||||
get() = when {
|
||||
isSystemCategory -> stringResource(id = R.string.label_default)
|
||||
else -> name
|
||||
}
|
||||
|
||||
fun Category.visualName(context: Context): String =
|
||||
when (id) {
|
||||
Category.UNCATEGORIZED_ID -> context.getString(R.string.label_default)
|
||||
when {
|
||||
isSystemCategory -> context.getString(R.string.label_default)
|
||||
else -> name
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import eu.kanade.tachiyomi.network.await
|
||||
import eu.kanade.tachiyomi.network.jsonMime
|
||||
import eu.kanade.tachiyomi.network.parseAs
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.serialization.json.JsonArray
|
||||
import kotlinx.serialization.json.JsonObject
|
||||
import kotlinx.serialization.json.buildJsonObject
|
||||
@ -127,16 +126,14 @@ class ShikimoriApi(private val client: OkHttpClient, interceptor: ShikimoriInter
|
||||
}
|
||||
}
|
||||
|
||||
fun getCurrentUser(): Int {
|
||||
return runBlocking {
|
||||
authClient.newCall(GET("$apiUrl/users/whoami"))
|
||||
suspend fun getCurrentUser(): Int {
|
||||
return authClient.newCall(GET("$apiUrl/users/whoami"))
|
||||
.await()
|
||||
.parseAs<JsonObject>()
|
||||
.let {
|
||||
it["id"]!!.jsonPrimitive.int
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun accessToken(code: String): OAuth {
|
||||
return withIOContext {
|
||||
|
@ -389,7 +389,7 @@ open class BrowseSourcePresenter(
|
||||
suspend fun getCategories(): List<DomainCategory> {
|
||||
return getCategories.subscribe()
|
||||
.firstOrNull()
|
||||
?.filterNot { it.id == DomainCategory.UNCATEGORIZED_ID }
|
||||
?.filterNot { it.isSystemCategory }
|
||||
?: emptyList()
|
||||
}
|
||||
|
||||
|
@ -32,14 +32,6 @@ import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
|
||||
/**
|
||||
* Presenter of [GlobalSearchController]
|
||||
* Function calls should be done from here. UI calls should be done from the controller.
|
||||
*
|
||||
* @param sourceManager manages the different sources.
|
||||
* @param db manages the database calls.
|
||||
* @param preferences manages the preference calls.
|
||||
*/
|
||||
open class GlobalSearchPresenter(
|
||||
private val initialQuery: String? = "",
|
||||
private val initialExtensionFilter: String? = null,
|
||||
@ -256,7 +248,7 @@ open class GlobalSearchPresenter(
|
||||
val networkManga = source.getMangaDetails(manga.toMangaInfo())
|
||||
manga.copyFrom(networkManga.toSManga())
|
||||
manga.initialized = true
|
||||
runBlocking { updateManga.await(manga.toDomainManga()!!.toMangaUpdate()) }
|
||||
updateManga.await(manga.toDomainManga()!!.toMangaUpdate())
|
||||
return manga
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ class LibraryPresenter(
|
||||
private fun getLibraryObservable(): Observable<Library> {
|
||||
return combine(getCategoriesFlow(), getLibraryMangasFlow()) { dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.isNotEmpty() && libraryManga.containsKey(0).not()) {
|
||||
dbCategories.filterNot { it.id == Category.UNCATEGORIZED_ID }
|
||||
dbCategories.filterNot { it.isSystemCategory }
|
||||
} else {
|
||||
dbCategories
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ import eu.kanade.tachiyomi.util.system.toast
|
||||
import eu.kanade.tachiyomi.widget.materialdialogs.QuadStateTextView
|
||||
import eu.kanade.tachiyomi.widget.materialdialogs.await
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import logcat.LogPriority
|
||||
import eu.kanade.domain.chapter.model.Chapter as DomainChapter
|
||||
|
||||
@ -214,7 +215,7 @@ class MangaController :
|
||||
}
|
||||
} else null,
|
||||
onRequireCategory = { manga, categories ->
|
||||
val ids = presenter.getMangaCategoryIds(manga)
|
||||
val ids = runBlocking { presenter.getMangaCategoryIds(manga) }
|
||||
val preselected = categories.map {
|
||||
if (it.id in ids) {
|
||||
QuadStateTextView.State.CHECKED.ordinal
|
||||
|
@ -64,7 +64,6 @@ import kotlinx.coroutines.flow.filter
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.supervisorScope
|
||||
import kotlinx.coroutines.withContext
|
||||
import logcat.LogPriority
|
||||
@ -351,7 +350,7 @@ class MangaPresenter(
|
||||
* @return List of categories, not including the default category
|
||||
*/
|
||||
suspend fun getCategories(): List<Category> {
|
||||
return getCategories.await()
|
||||
return getCategories.await().filterNot { it.isSystemCategory }
|
||||
}
|
||||
|
||||
/**
|
||||
@ -360,8 +359,8 @@ class MangaPresenter(
|
||||
* @param manga the manga to get categories from.
|
||||
* @return Array of category ids the manga is in, if none returns default id
|
||||
*/
|
||||
fun getMangaCategoryIds(manga: DomainManga): Array<Long> {
|
||||
val categories = runBlocking { getCategories.await(manga.id) }
|
||||
suspend fun getMangaCategoryIds(manga: DomainManga): Array<Long> {
|
||||
val categories = getCategories.await(manga.id)
|
||||
return categories.map { it.id }.toTypedArray()
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,9 @@ import eu.kanade.tachiyomi.data.updater.AppUpdateChecker
|
||||
import eu.kanade.tachiyomi.data.updater.AppUpdateResult
|
||||
import eu.kanade.tachiyomi.ui.base.controller.BasicFullComposeController
|
||||
import eu.kanade.tachiyomi.ui.base.controller.pushController
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.toDateTimestampString
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import logcat.LogPriority
|
||||
@ -43,9 +44,11 @@ class AboutController : BasicFullComposeController() {
|
||||
|
||||
activity!!.toast(R.string.update_check_look_for_updates)
|
||||
|
||||
launchNow {
|
||||
viewScope.launchIO {
|
||||
val result = updateChecker.checkForUpdate(activity!!, isUserPrompt = true)
|
||||
withUIContext {
|
||||
try {
|
||||
when (val result = updateChecker.checkForUpdate(activity!!, isUserPrompt = true)) {
|
||||
when (result) {
|
||||
is AppUpdateResult.NewUpdate -> {
|
||||
NewUpdateDialogController(result).showDialog(router)
|
||||
}
|
||||
@ -60,6 +63,7 @@ class AboutController : BasicFullComposeController() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getFormattedBuildTime(): String {
|
||||
return try {
|
||||
|
Loading…
Reference in New Issue
Block a user