mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
revert: "Migrate even more stuff to use SQLDelight"
This reverts commit c7ef06717d
.
This commit is contained in:
parent
cc5a6ac7a8
commit
ac95e32c8b
4 changed files with 47 additions and 37 deletions
|
@ -11,3 +11,8 @@
|
||||||
-->
|
-->
|
||||||
## Fixes
|
## Fixes
|
||||||
- Fixed crashes caused by certain extension implementation
|
- Fixed crashes caused by certain extension implementation
|
||||||
|
|
||||||
|
## Other
|
||||||
|
- More StorIO to SQLDelight migration effort
|
||||||
|
- Update dependency gradle to v8.10
|
||||||
|
- Update dependency dev.chrisbanes.compose:compose-bom to v2024.08.00-alpha02
|
||||||
|
|
|
@ -6,6 +6,9 @@ import com.pushtorefresh.storio.sqlite.queries.Query
|
||||||
import com.pushtorefresh.storio.sqlite.queries.RawQuery
|
import com.pushtorefresh.storio.sqlite.queries.RawQuery
|
||||||
import eu.kanade.tachiyomi.data.database.DbProvider
|
import eu.kanade.tachiyomi.data.database.DbProvider
|
||||||
import eu.kanade.tachiyomi.data.database.models.SourceIdMangaCount
|
import eu.kanade.tachiyomi.data.database.models.SourceIdMangaCount
|
||||||
|
import eu.kanade.tachiyomi.data.database.resolvers.MangaDateAddedPutResolver
|
||||||
|
import eu.kanade.tachiyomi.data.database.resolvers.MangaFavoritePutResolver
|
||||||
|
import eu.kanade.tachiyomi.data.database.resolvers.MangaTitlePutResolver
|
||||||
import eu.kanade.tachiyomi.data.database.resolvers.SourceIdMangaCountGetResolver
|
import eu.kanade.tachiyomi.data.database.resolvers.SourceIdMangaCountGetResolver
|
||||||
import eu.kanade.tachiyomi.data.database.tables.ChapterTable
|
import eu.kanade.tachiyomi.data.database.tables.ChapterTable
|
||||||
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
import eu.kanade.tachiyomi.data.database.tables.MangaTable
|
||||||
|
@ -75,6 +78,24 @@ interface MangaQueries : DbProvider {
|
||||||
|
|
||||||
fun insertManga(manga: Manga) = db.put().`object`(manga).prepare()
|
fun insertManga(manga: Manga) = db.put().`object`(manga).prepare()
|
||||||
|
|
||||||
|
// FIXME: Migrate to SQLDelight, on halt: used by StorIO's inTransaction
|
||||||
|
fun updateMangaFavorite(manga: Manga) = db.put()
|
||||||
|
.`object`(manga)
|
||||||
|
.withPutResolver(MangaFavoritePutResolver())
|
||||||
|
.prepare()
|
||||||
|
|
||||||
|
// FIXME: Migrate to SQLDelight, on halt: used by StorIO's inTransaction
|
||||||
|
fun updateMangaAdded(manga: Manga) = db.put()
|
||||||
|
.`object`(manga)
|
||||||
|
.withPutResolver(MangaDateAddedPutResolver())
|
||||||
|
.prepare()
|
||||||
|
|
||||||
|
// FIXME: Migrate to SQLDelight, on halt: used by StorIO's inTransaction
|
||||||
|
fun updateMangaTitle(manga: Manga) = db.put()
|
||||||
|
.`object`(manga)
|
||||||
|
.withPutResolver(MangaTitlePutResolver())
|
||||||
|
.prepare()
|
||||||
|
|
||||||
fun deleteMangasNotInLibraryBySourceIds(sourceIds: List<Long>) = db.delete()
|
fun deleteMangasNotInLibraryBySourceIds(sourceIds: List<Long>) = db.delete()
|
||||||
.byQuery(
|
.byQuery(
|
||||||
DeleteQuery.builder()
|
DeleteQuery.builder()
|
||||||
|
|
|
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.domain.manga.models.Manga
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
import eu.kanade.tachiyomi.ui.migration.MigrationFlags
|
||||||
|
import eu.kanade.tachiyomi.util.system.launchNow
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
import eu.kanade.tachiyomi.util.system.launchUI
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
@ -23,11 +24,7 @@ import kotlinx.coroutines.withContext
|
||||||
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.chapter.interactor.GetChapter
|
|
||||||
import yokai.domain.library.custom.model.CustomMangaInfo.Companion.getMangaInfo
|
import yokai.domain.library.custom.model.CustomMangaInfo.Companion.getMangaInfo
|
||||||
import yokai.domain.manga.interactor.GetManga
|
|
||||||
import yokai.domain.manga.interactor.UpdateManga
|
|
||||||
import yokai.domain.manga.models.MangaUpdate
|
|
||||||
import yokai.domain.ui.UiPreferences
|
import yokai.domain.ui.UiPreferences
|
||||||
|
|
||||||
class MigrationProcessAdapter(
|
class MigrationProcessAdapter(
|
||||||
|
@ -35,15 +32,12 @@ class MigrationProcessAdapter(
|
||||||
) : FlexibleAdapter<MigrationProcessItem>(null, controller, true) {
|
) : FlexibleAdapter<MigrationProcessItem>(null, controller, true) {
|
||||||
|
|
||||||
private val db: DatabaseHelper by injectLazy()
|
private val db: DatabaseHelper by injectLazy()
|
||||||
|
|
||||||
private val getManga: GetManga by injectLazy()
|
|
||||||
|
|
||||||
var items: List<MigrationProcessItem> = emptyList()
|
var items: List<MigrationProcessItem> = emptyList()
|
||||||
val preferences: PreferencesHelper by injectLazy()
|
val preferences: PreferencesHelper by injectLazy()
|
||||||
val uiPreferences: UiPreferences by injectLazy()
|
val uiPreferences: UiPreferences by injectLazy()
|
||||||
val sourceManager: SourceManager by injectLazy()
|
val sourceManager: SourceManager by injectLazy()
|
||||||
val coverCache: CoverCache by injectLazy()
|
val coverCache: CoverCache by injectLazy()
|
||||||
private val customMangaManager: CustomMangaManager by injectLazy()
|
val customMangaManager: CustomMangaManager by injectLazy()
|
||||||
|
|
||||||
var showOutline = uiPreferences.outlineOnCovers().get()
|
var showOutline = uiPreferences.outlineOnCovers().get()
|
||||||
val menuItemListener: MigrationProcessInterface = controller
|
val menuItemListener: MigrationProcessInterface = controller
|
||||||
|
@ -86,7 +80,9 @@ class MigrationProcessAdapter(
|
||||||
val manga = migratingManga.manga
|
val manga = migratingManga.manga
|
||||||
if (manga.searchResult.initialized) {
|
if (manga.searchResult.initialized) {
|
||||||
val toMangaObj =
|
val toMangaObj =
|
||||||
getManga.awaitById(manga.searchResult.get() ?: return@forEach) ?: return@forEach
|
db.getManga(manga.searchResult.get() ?: return@forEach)
|
||||||
|
.executeAsBlocking()
|
||||||
|
?: return@forEach
|
||||||
val prevManga = manga.manga() ?: return@forEach
|
val prevManga = manga.manga() ?: return@forEach
|
||||||
val source = sourceManager.get(toMangaObj.source) ?: return@forEach
|
val source = sourceManager.get(toMangaObj.source) ?: return@forEach
|
||||||
val prevSource = sourceManager.get(prevManga.source)
|
val prevSource = sourceManager.get(prevManga.source)
|
||||||
|
@ -107,7 +103,9 @@ class MigrationProcessAdapter(
|
||||||
launchUI {
|
launchUI {
|
||||||
val manga = getItem(position)?.manga ?: return@launchUI
|
val manga = getItem(position)?.manga ?: return@launchUI
|
||||||
db.inTransaction {
|
db.inTransaction {
|
||||||
val toMangaObj = getManga.awaitById(manga.searchResult.get() ?: return@launchUI) ?: return@launchUI
|
val toMangaObj =
|
||||||
|
db.getManga(manga.searchResult.get() ?: return@launchUI).executeAsBlocking()
|
||||||
|
?: return@launchUI
|
||||||
val prevManga = manga.manga() ?: return@launchUI
|
val prevManga = manga.manga() ?: return@launchUI
|
||||||
val source = sourceManager.get(toMangaObj.source) ?: return@launchUI
|
val source = sourceManager.get(toMangaObj.source) ?: return@launchUI
|
||||||
val prevSource = sourceManager.get(prevManga.source)
|
val prevSource = sourceManager.get(prevManga.source)
|
||||||
|
@ -133,7 +131,7 @@ class MigrationProcessAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Migrate to SQLDelight, on halt: in StorIO transaction
|
// FIXME: Migrate to SQLDelight, on halt: in StorIO transaction
|
||||||
private suspend fun migrateMangaInternal(
|
private fun migrateMangaInternal(
|
||||||
prevSource: Source?,
|
prevSource: Source?,
|
||||||
source: Source,
|
source: Source,
|
||||||
prevManga: Manga,
|
prevManga: Manga,
|
||||||
|
@ -148,7 +146,7 @@ class MigrationProcessAdapter(
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
// FIXME: Migrate to SQLDelight, on halt: in StorIO transaction
|
// FIXME: Migrate to SQLDelight, on halt: in StorIO transaction
|
||||||
suspend fun migrateMangaInternal(
|
fun migrateMangaInternal(
|
||||||
flags: Int,
|
flags: Int,
|
||||||
db: DatabaseHelper,
|
db: DatabaseHelper,
|
||||||
enhancedServices: List<EnhancedTrackService>,
|
enhancedServices: List<EnhancedTrackService>,
|
||||||
|
@ -159,16 +157,13 @@ class MigrationProcessAdapter(
|
||||||
prevManga: Manga,
|
prevManga: Manga,
|
||||||
manga: Manga,
|
manga: Manga,
|
||||||
replace: Boolean,
|
replace: Boolean,
|
||||||
getChapter: GetChapter = Injekt.get(),
|
|
||||||
//insertChapter: InsertChapter = Injekt.get(),
|
|
||||||
updateManga: UpdateManga = Injekt.get(),
|
|
||||||
) {
|
) {
|
||||||
// Update chapters read
|
// Update chapters read
|
||||||
if (MigrationFlags.hasChapters(flags)) {
|
if (MigrationFlags.hasChapters(flags)) {
|
||||||
val prevMangaChapters = getChapter.awaitAll(prevManga.id!!, false)
|
val prevMangaChapters = db.getChapters(prevManga).executeAsBlocking()
|
||||||
val maxChapterRead =
|
val maxChapterRead =
|
||||||
prevMangaChapters.filter { it.read }.maxOfOrNull { it.chapter_number } ?: 0f
|
prevMangaChapters.filter { it.read }.maxOfOrNull { it.chapter_number } ?: 0f
|
||||||
val dbChapters = getChapter.awaitAll(manga.id!!, false)
|
val dbChapters = db.getChapters(manga).executeAsBlocking()
|
||||||
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
|
val prevHistoryList = db.getHistoryByMangaId(prevManga.id!!).executeAsBlocking()
|
||||||
val historyList = mutableListOf<History>()
|
val historyList = mutableListOf<History>()
|
||||||
for (chapter in dbChapters) {
|
for (chapter in dbChapters) {
|
||||||
|
@ -193,8 +188,6 @@ class MigrationProcessAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FIXME: Probably gonna mess with StorIO's transaction since it's also uses transaction
|
|
||||||
//insertChapter.awaitBulk(dbChapters)
|
|
||||||
db.insertChapters(dbChapters).executeAsBlocking()
|
db.insertChapters(dbChapters).executeAsBlocking()
|
||||||
db.upsertHistoryLastRead(historyList).executeAsBlocking()
|
db.upsertHistoryLastRead(historyList).executeAsBlocking()
|
||||||
}
|
}
|
||||||
|
@ -224,12 +217,7 @@ class MigrationProcessAdapter(
|
||||||
// Update favorite status
|
// Update favorite status
|
||||||
if (replace) {
|
if (replace) {
|
||||||
prevManga.favorite = false
|
prevManga.favorite = false
|
||||||
updateManga.await(
|
db.updateMangaFavorite(prevManga).executeAsBlocking()
|
||||||
MangaUpdate(
|
|
||||||
id = prevManga.id!!,
|
|
||||||
favorite = prevManga.favorite,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
manga.favorite = true
|
manga.favorite = true
|
||||||
if (replace) {
|
if (replace) {
|
||||||
|
@ -242,21 +230,18 @@ class MigrationProcessAdapter(
|
||||||
if (MigrationFlags.hasCustomMangaInfo(flags)) {
|
if (MigrationFlags.hasCustomMangaInfo(flags)) {
|
||||||
if (coverCache.getCustomCoverFile(prevManga).exists()) {
|
if (coverCache.getCustomCoverFile(prevManga).exists()) {
|
||||||
coverCache.setCustomCoverToCache(manga, coverCache.getCustomCoverFile(prevManga).inputStream())
|
coverCache.setCustomCoverToCache(manga, coverCache.getCustomCoverFile(prevManga).inputStream())
|
||||||
manga.updateCoverLastModified()
|
launchNow { manga.updateCoverLastModified() }
|
||||||
}
|
}
|
||||||
customMangaManager.getManga(prevManga)?.let { customManga ->
|
customMangaManager.getManga(prevManga)?.let { customManga ->
|
||||||
customMangaManager.updateMangaInfo(prevManga.id, manga.id, customManga.getMangaInfo())
|
launchNow {
|
||||||
|
customMangaManager.updateMangaInfo(prevManga.id, manga.id, customManga.getMangaInfo())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateManga.await(
|
db.updateMangaFavorite(manga).executeAsBlocking()
|
||||||
MangaUpdate(
|
db.updateMangaAdded(manga).executeAsBlocking()
|
||||||
id = manga.id!!,
|
db.updateMangaTitle(manga).executeAsBlocking()
|
||||||
favorite = manga.favorite,
|
|
||||||
dateAdded = manga.date_added,
|
|
||||||
title = manga.title,
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ import eu.kanade.tachiyomi.ui.migration.manga.process.MigrationProcessAdapter
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithTrackServiceTwoWay
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithTrackServiceTwoWay
|
||||||
import eu.kanade.tachiyomi.util.lang.asButton
|
import eu.kanade.tachiyomi.util.lang.asButton
|
||||||
import eu.kanade.tachiyomi.util.system.launchIO
|
import eu.kanade.tachiyomi.util.system.launchIO
|
||||||
import eu.kanade.tachiyomi.util.system.launchUI
|
|
||||||
import eu.kanade.tachiyomi.util.system.materialAlertDialog
|
import eu.kanade.tachiyomi.util.system.materialAlertDialog
|
||||||
import eu.kanade.tachiyomi.util.system.setCustomTitleAndMessage
|
import eu.kanade.tachiyomi.util.system.setCustomTitleAndMessage
|
||||||
import eu.kanade.tachiyomi.util.system.toast
|
import eu.kanade.tachiyomi.util.system.toast
|
||||||
|
@ -330,7 +329,7 @@ private fun showAddDuplicateDialog(
|
||||||
val source = sourceManager.getOrStub(libraryManga.source)
|
val source = sourceManager.getOrStub(libraryManga.source)
|
||||||
|
|
||||||
val titles by lazy { MigrationFlags.titles(activity, libraryManga) }
|
val titles by lazy { MigrationFlags.titles(activity, libraryManga) }
|
||||||
fun migrateManga(mDialog: DialogInterface, replace: Boolean) = launchUI {
|
fun migrateManga(mDialog: DialogInterface, replace: Boolean) {
|
||||||
val listView = (mDialog as AlertDialog).listView
|
val listView = (mDialog as AlertDialog).listView
|
||||||
val enabled = titles.indices.map { listView.isItemChecked(it) }.toTypedArray()
|
val enabled = titles.indices.map { listView.isItemChecked(it) }.toTypedArray()
|
||||||
val flags = MigrationFlags.getFlagsFromPositions(enabled, libraryManga)
|
val flags = MigrationFlags.getFlagsFromPositions(enabled, libraryManga)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue