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