mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Migrated getMangas to SQLDelight
This commit is contained in:
parent
f6080cd5eb
commit
395f10c8a9
3 changed files with 8 additions and 13 deletions
|
@ -16,15 +16,6 @@ import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
||||||
|
|
||||||
interface MangaQueries : DbProvider {
|
interface MangaQueries : DbProvider {
|
||||||
|
|
||||||
fun getMangas() = db.get()
|
|
||||||
.listOfObjects(Manga::class.java)
|
|
||||||
.withQuery(
|
|
||||||
Query.builder()
|
|
||||||
.table(MangaTable.TABLE)
|
|
||||||
.build(),
|
|
||||||
)
|
|
||||||
.prepare()
|
|
||||||
|
|
||||||
fun getDuplicateLibraryManga(manga: Manga) = db.get()
|
fun getDuplicateLibraryManga(manga: Manga) = db.get()
|
||||||
.`object`(Manga::class.java)
|
.`object`(Manga::class.java)
|
||||||
.withQuery(
|
.withQuery(
|
||||||
|
|
|
@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.data.download
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
@ -12,9 +11,11 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.Job
|
import kotlinx.coroutines.Job
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
import uy.kohesive.injekt.Injekt
|
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
|
||||||
|
import yokai.domain.manga.interactor.GetManga
|
||||||
import yokai.domain.storage.StorageManager
|
import yokai.domain.storage.StorageManager
|
||||||
import java.util.concurrent.*
|
import java.util.concurrent.*
|
||||||
|
|
||||||
|
@ -131,8 +132,8 @@ class DownloadCache(
|
||||||
onlineSources.find { provider.getSourceDirName(it).equals(entry.key, ignoreCase = true) }?.id
|
onlineSources.find { provider.getSourceDirName(it).equals(entry.key, ignoreCase = true) }?.id
|
||||||
}
|
}
|
||||||
|
|
||||||
val db: DatabaseHelper by injectLazy()
|
val getManga: GetManga by injectLazy()
|
||||||
val mangas = db.getMangas().executeAsBlocking().groupBy { it.source }
|
val mangas = runBlocking(Dispatchers.IO) { getManga.awaitAll().groupBy { it.source } }
|
||||||
|
|
||||||
sourceDirs.forEach { sourceValue ->
|
sourceDirs.forEach { sourceValue ->
|
||||||
val sourceMangaRaw = mangas[sourceValue.key]?.toMutableSet() ?: return@forEach
|
val sourceMangaRaw = mangas[sourceValue.key]?.toMutableSet() ?: return@forEach
|
||||||
|
|
|
@ -79,6 +79,7 @@ import uy.kohesive.injekt.api.get
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import yokai.domain.base.BasePreferences.ExtensionInstaller
|
import yokai.domain.base.BasePreferences.ExtensionInstaller
|
||||||
import yokai.domain.extension.interactor.TrustExtension
|
import yokai.domain.extension.interactor.TrustExtension
|
||||||
|
import yokai.domain.manga.interactor.GetManga
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class SettingsAdvancedController : SettingsLegacyController() {
|
class SettingsAdvancedController : SettingsLegacyController() {
|
||||||
|
@ -88,6 +89,8 @@ class SettingsAdvancedController : SettingsLegacyController() {
|
||||||
|
|
||||||
private val db: DatabaseHelper by injectLazy()
|
private val db: DatabaseHelper by injectLazy()
|
||||||
|
|
||||||
|
private val getManga: GetManga by injectLazy()
|
||||||
|
|
||||||
private val downloadManager: DownloadManager by injectLazy()
|
private val downloadManager: DownloadManager by injectLazy()
|
||||||
|
|
||||||
private val trustExtension: TrustExtension by injectLazy()
|
private val trustExtension: TrustExtension by injectLazy()
|
||||||
|
@ -404,7 +407,7 @@ class SettingsAdvancedController : SettingsLegacyController() {
|
||||||
if (job?.isActive == true) return
|
if (job?.isActive == true) return
|
||||||
activity?.toast(R.string.starting_cleanup)
|
activity?.toast(R.string.starting_cleanup)
|
||||||
job = GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) {
|
job = GlobalScope.launch(Dispatchers.IO, CoroutineStart.DEFAULT) {
|
||||||
val mangaList = db.getMangas().executeAsBlocking()
|
val mangaList = getManga.awaitAll()
|
||||||
val sourceManager: SourceManager = Injekt.get()
|
val sourceManager: SourceManager = Injekt.get()
|
||||||
val downloadProvider = DownloadProvider(activity!!)
|
val downloadProvider = DownloadProvider(activity!!)
|
||||||
var foldersCleared = 0
|
var foldersCleared = 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue