Upgrade to SQLDelight 2
(cherry picked from commit 6a558ad119ff35336c2141deefc5da4b49cf4553) # Conflicts: # app/build.gradle.kts # app/src/main/java/eu/kanade/tachiyomi/AppModule.kt # data/src/main/java/tachiyomi/data/manga/MangaMapper.kt # data/src/main/java/tachiyomi/data/manga/MangaRepositoryImpl.kt # data/src/main/sqldelight/tachiyomi/data/mangas.sq
This commit is contained in:
parent
bc898118b8
commit
af41e65b3d
@ -168,6 +168,7 @@ dependencies {
|
||||
implementation(androidx.paging.compose)
|
||||
|
||||
implementation(libs.bundles.sqlite)
|
||||
implementation(libs.sqldelight.primitive.adapters)
|
||||
// SY -->
|
||||
implementation(libs.sqlcipher)
|
||||
// SY <--
|
||||
|
@ -5,8 +5,10 @@ import android.os.Build
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
import androidx.sqlite.db.framework.FrameworkSQLiteOpenHelperFactory
|
||||
import com.squareup.sqldelight.android.AndroidSqliteDriver
|
||||
import com.squareup.sqldelight.db.SqlDriver
|
||||
import app.cash.sqldelight.adapter.primitive.FloatColumnAdapter
|
||||
import app.cash.sqldelight.adapter.primitive.IntColumnAdapter
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import app.cash.sqldelight.driver.android.AndroidSqliteDriver
|
||||
import eu.kanade.domain.base.BasePreferences
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.domain.track.service.TrackPreferences
|
||||
@ -42,13 +44,16 @@ import tachiyomi.core.preference.PreferenceStore
|
||||
import tachiyomi.core.provider.AndroidBackupFolderProvider
|
||||
import tachiyomi.core.provider.AndroidDownloadFolderProvider
|
||||
import tachiyomi.data.AndroidDatabaseHandler
|
||||
import tachiyomi.data.Categories
|
||||
import tachiyomi.data.Chapters
|
||||
import tachiyomi.data.Database
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
import tachiyomi.data.History
|
||||
import tachiyomi.data.Manga_sync
|
||||
import tachiyomi.data.Mangas
|
||||
import tachiyomi.data.Search_metadata
|
||||
import tachiyomi.data.Search_tags
|
||||
import tachiyomi.data.Search_titles
|
||||
import tachiyomi.data.dateAdapter
|
||||
import tachiyomi.data.listOfLongsAdapter
|
||||
import tachiyomi.data.listOfStringsAdapter
|
||||
import tachiyomi.data.listOfStringsAndAdapter
|
||||
import tachiyomi.data.updateStrategyAdapter
|
||||
@ -122,9 +127,15 @@ class AppModule(val app: Application) : InjektModule {
|
||||
addSingletonFactory {
|
||||
Database(
|
||||
driver = get(),
|
||||
chaptersAdapter = Chapters.Adapter(
|
||||
chapter_numberAdapter = FloatColumnAdapter,
|
||||
),
|
||||
historyAdapter = History.Adapter(
|
||||
last_readAdapter = dateAdapter,
|
||||
),
|
||||
manga_syncAdapter = Manga_sync.Adapter(
|
||||
scoreAdapter = FloatColumnAdapter,
|
||||
),
|
||||
mangasAdapter = Mangas.Adapter(
|
||||
genreAdapter = listOfStringsAdapter,
|
||||
update_strategyAdapter = updateStrategyAdapter,
|
||||
@ -132,11 +143,15 @@ class AppModule(val app: Application) : InjektModule {
|
||||
filtered_scanlatorsAdapter = listOfStringsAndAdapter,
|
||||
// SY <--
|
||||
),
|
||||
// SY -->
|
||||
categoriesAdapter = Categories.Adapter(
|
||||
manga_orderAdapter = listOfLongsAdapter,
|
||||
search_metadataAdapter = Search_metadata.Adapter(
|
||||
extra_versionAdapter = IntColumnAdapter,
|
||||
),
|
||||
search_tagsAdapter = Search_tags.Adapter(
|
||||
typeAdapter = IntColumnAdapter,
|
||||
),
|
||||
search_titlesAdapter = Search_titles.Adapter(
|
||||
typeAdapter = IntColumnAdapter,
|
||||
),
|
||||
// SY <--
|
||||
)
|
||||
}
|
||||
addSingletonFactory<DatabaseHandler> { AndroidDatabaseHandler(get(), get()) }
|
||||
|
@ -333,7 +333,7 @@ class BackupManager(
|
||||
}
|
||||
if (!found) {
|
||||
// Let the db assign the id
|
||||
val id = handler.awaitOne {
|
||||
val id = handler.awaitOneExecutable {
|
||||
categoriesQueries.insert(category.name, category.order, category.flags)
|
||||
categoriesQueries.selectLastInsertedRowId()
|
||||
}
|
||||
@ -557,7 +557,7 @@ class BackupManager(
|
||||
* @return id of [Manga], null if not found
|
||||
*/
|
||||
private suspend fun insertManga(manga: Manga): Long {
|
||||
return handler.awaitOne(true) {
|
||||
return handler.awaitOneExecutable(true) {
|
||||
mangasQueries.insert(
|
||||
source = manga.source,
|
||||
url = manga.url,
|
||||
@ -598,11 +598,11 @@ class BackupManager(
|
||||
title = manga.title,
|
||||
status = manga.status,
|
||||
thumbnailUrl = manga.thumbnailUrl,
|
||||
favorite = manga.favorite.toLong(),
|
||||
favorite = manga.favorite,
|
||||
lastUpdate = manga.lastUpdate,
|
||||
nextUpdate = null,
|
||||
calculateInterval = null,
|
||||
initialized = manga.initialized.toLong(),
|
||||
initialized = manga.initialized,
|
||||
viewer = manga.viewerFlags,
|
||||
chapterFlags = manga.chapterFlags,
|
||||
coverLastModified = manga.coverLastModified,
|
||||
@ -651,8 +651,8 @@ class BackupManager(
|
||||
url = null,
|
||||
name = null,
|
||||
scanlator = null,
|
||||
read = chapter.read.toLong(),
|
||||
bookmark = chapter.bookmark.toLong(),
|
||||
read = chapter.read,
|
||||
bookmark = chapter.bookmark,
|
||||
lastPageRead = chapter.lastPageRead,
|
||||
chapterNumber = null,
|
||||
sourceOrder = null,
|
||||
|
@ -2,7 +2,7 @@ plugins {
|
||||
id("com.android.library")
|
||||
kotlin("android")
|
||||
kotlin("plugin.serialization")
|
||||
id("com.squareup.sqldelight")
|
||||
id("app.cash.sqldelight")
|
||||
}
|
||||
|
||||
android {
|
||||
@ -13,10 +13,12 @@ android {
|
||||
}
|
||||
|
||||
sqldelight {
|
||||
database("Database") {
|
||||
packageName = "tachiyomi.data"
|
||||
dialect = "sqlite:3.24"
|
||||
schemaOutputDirectory = project.file("./src/main/sqldelight")
|
||||
databases {
|
||||
create("Database") {
|
||||
packageName.set("tachiyomi.data")
|
||||
dialect(libs.sqldelight.dialects.sql)
|
||||
schemaOutputDirectory.set(project.file("./src/main/sqldelight"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -26,9 +28,7 @@ dependencies {
|
||||
implementation(project(":domain"))
|
||||
implementation(project(":core"))
|
||||
|
||||
api(libs.sqldelight.android.driver)
|
||||
api(libs.sqldelight.coroutines)
|
||||
api(libs.sqldelight.android.paging)
|
||||
api(libs.bundles.sqldelight)
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
@ -1,12 +1,13 @@
|
||||
package tachiyomi.data
|
||||
|
||||
import androidx.paging.PagingSource
|
||||
import com.squareup.sqldelight.Query
|
||||
import com.squareup.sqldelight.db.SqlDriver
|
||||
import com.squareup.sqldelight.runtime.coroutines.asFlow
|
||||
import com.squareup.sqldelight.runtime.coroutines.mapToList
|
||||
import com.squareup.sqldelight.runtime.coroutines.mapToOne
|
||||
import com.squareup.sqldelight.runtime.coroutines.mapToOneOrNull
|
||||
import app.cash.sqldelight.ExecutableQuery
|
||||
import app.cash.sqldelight.Query
|
||||
import app.cash.sqldelight.coroutines.asFlow
|
||||
import app.cash.sqldelight.coroutines.mapToList
|
||||
import app.cash.sqldelight.coroutines.mapToOne
|
||||
import app.cash.sqldelight.coroutines.mapToOneOrNull
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@ -32,6 +33,15 @@ class AndroidDatabaseHandler(
|
||||
return dispatch(inTransaction) { block(db).executeAsList() }
|
||||
}
|
||||
|
||||
// SY -->
|
||||
override suspend fun <T : Any> awaitListExecutable(
|
||||
inTransaction: Boolean,
|
||||
block: suspend Database.() -> ExecutableQuery<T>,
|
||||
): List<T> {
|
||||
return dispatch(inTransaction) { block(db).executeAsList() }
|
||||
}
|
||||
// SY <--
|
||||
|
||||
override suspend fun <T : Any> awaitOne(
|
||||
inTransaction: Boolean,
|
||||
block: suspend Database.() -> Query<T>,
|
||||
@ -39,6 +49,13 @@ class AndroidDatabaseHandler(
|
||||
return dispatch(inTransaction) { block(db).executeAsOne() }
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> awaitOneExecutable(
|
||||
inTransaction: Boolean,
|
||||
block: suspend Database.() -> ExecutableQuery<T>,
|
||||
): T {
|
||||
return dispatch(inTransaction) { block(db).executeAsOne() }
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> awaitOneOrNull(
|
||||
inTransaction: Boolean,
|
||||
block: suspend Database.() -> Query<T>,
|
||||
@ -46,6 +63,13 @@ class AndroidDatabaseHandler(
|
||||
return dispatch(inTransaction) { block(db).executeAsOneOrNull() }
|
||||
}
|
||||
|
||||
override suspend fun <T : Any> awaitOneOrNullExecutable(
|
||||
inTransaction: Boolean,
|
||||
block: suspend Database.() -> ExecutableQuery<T>,
|
||||
): T? {
|
||||
return dispatch(inTransaction) { block(db).executeAsOneOrNull() }
|
||||
}
|
||||
|
||||
override fun <T : Any> subscribeToList(block: Database.() -> Query<T>): Flow<List<T>> {
|
||||
return block(db).asFlow().mapToList(queryDispatcher)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package tachiyomi.data
|
||||
|
||||
import com.squareup.sqldelight.ColumnAdapter
|
||||
import app.cash.sqldelight.ColumnAdapter
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy
|
||||
import java.util.Date
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
package tachiyomi.data
|
||||
|
||||
import androidx.paging.PagingSource
|
||||
import com.squareup.sqldelight.Query
|
||||
import app.cash.sqldelight.ExecutableQuery
|
||||
import app.cash.sqldelight.Query
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
interface DatabaseHandler {
|
||||
@ -13,16 +14,33 @@ interface DatabaseHandler {
|
||||
block: suspend Database.() -> Query<T>,
|
||||
): List<T>
|
||||
|
||||
// SY -->
|
||||
suspend fun <T : Any> awaitListExecutable(
|
||||
inTransaction: Boolean = false,
|
||||
block: suspend Database.() -> ExecutableQuery<T>,
|
||||
): List<T>
|
||||
// SY <--
|
||||
|
||||
suspend fun <T : Any> awaitOne(
|
||||
inTransaction: Boolean = false,
|
||||
block: suspend Database.() -> Query<T>,
|
||||
): T
|
||||
|
||||
suspend fun <T : Any> awaitOneExecutable(
|
||||
inTransaction: Boolean = false,
|
||||
block: suspend Database.() -> ExecutableQuery<T>,
|
||||
): T
|
||||
|
||||
suspend fun <T : Any> awaitOneOrNull(
|
||||
inTransaction: Boolean = false,
|
||||
block: suspend Database.() -> Query<T>,
|
||||
): T?
|
||||
|
||||
suspend fun <T : Any> awaitOneOrNullExecutable(
|
||||
inTransaction: Boolean = false,
|
||||
block: suspend Database.() -> ExecutableQuery<T>,
|
||||
): T?
|
||||
|
||||
fun <T : Any> subscribeToList(block: Database.() -> Query<T>): Flow<List<T>>
|
||||
|
||||
fun <T : Any> subscribeToOne(block: Database.() -> Query<T>): Flow<T>
|
||||
|
@ -1,9 +1,9 @@
|
||||
package tachiyomi.data
|
||||
|
||||
import com.squareup.sqldelight.Query
|
||||
import com.squareup.sqldelight.db.SqlCursor
|
||||
import com.squareup.sqldelight.db.SqlDriver
|
||||
import com.squareup.sqldelight.internal.copyOnWriteList
|
||||
import app.cash.sqldelight.ExecutableQuery
|
||||
import app.cash.sqldelight.db.QueryResult
|
||||
import app.cash.sqldelight.db.SqlCursor
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import tachiyomi.view.LibraryView
|
||||
|
||||
@ -33,11 +33,11 @@ private val mapper = { cursor: SqlCursor ->
|
||||
last_modified_at = cursor.getLong(21)!!,
|
||||
favorite_modified_at = cursor.getLong(22),
|
||||
totalCount = cursor.getLong(23)!!,
|
||||
readCount = cursor.getLong(24)!!,
|
||||
readCount = cursor.getDouble(24)!!,
|
||||
latestUpload = cursor.getLong(25)!!,
|
||||
chapterFetchedAt = cursor.getLong(26)!!,
|
||||
lastRead = cursor.getLong(27)!!,
|
||||
bookmarkCount = cursor.getLong(28)!!,
|
||||
bookmarkCount = cursor.getDouble(28)!!,
|
||||
category = cursor.getLong(29)!!,
|
||||
)
|
||||
}
|
||||
@ -45,8 +45,9 @@ private val mapper = { cursor: SqlCursor ->
|
||||
class LibraryQuery(
|
||||
val driver: SqlDriver,
|
||||
val condition: String = "M.favorite = 1",
|
||||
) : Query<LibraryView>(copyOnWriteList(), mapper) {
|
||||
override fun execute(): SqlCursor {
|
||||
) : ExecutableQuery<LibraryView>(mapper) {
|
||||
|
||||
override fun <R> execute(mapper: (SqlCursor) -> QueryResult<R>): QueryResult<R> {
|
||||
return driver.executeQuery(
|
||||
null,
|
||||
"""
|
||||
@ -116,7 +117,8 @@ class LibraryQuery(
|
||||
ON MC.manga_id = M._id
|
||||
WHERE $condition AND M.source = $MERGED_SOURCE_ID;
|
||||
""".trimIndent(),
|
||||
1,
|
||||
mapper,
|
||||
parameters = 0,
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package tachiyomi.data
|
||||
|
||||
import androidx.paging.PagingSource
|
||||
import androidx.paging.PagingState
|
||||
import com.squareup.sqldelight.Query
|
||||
import app.cash.sqldelight.Query
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class QueryPagingSource<RowType : Any>(
|
||||
|
@ -1,9 +1,9 @@
|
||||
package tachiyomi.data
|
||||
|
||||
import com.squareup.sqldelight.Query
|
||||
import com.squareup.sqldelight.db.SqlCursor
|
||||
import com.squareup.sqldelight.db.SqlDriver
|
||||
import com.squareup.sqldelight.internal.copyOnWriteList
|
||||
import app.cash.sqldelight.ExecutableQuery
|
||||
import app.cash.sqldelight.db.QueryResult
|
||||
import app.cash.sqldelight.db.SqlCursor
|
||||
import app.cash.sqldelight.db.SqlDriver
|
||||
import exh.source.MERGED_SOURCE_ID
|
||||
import tachiyomi.view.UpdatesView
|
||||
|
||||
@ -26,8 +26,8 @@ private val mapper = { cursor: SqlCursor ->
|
||||
)
|
||||
}
|
||||
|
||||
class UpdatesQuery(val driver: SqlDriver, val after: Long, val limit: Long) : Query<UpdatesView>(copyOnWriteList(), mapper) {
|
||||
override fun execute(): SqlCursor {
|
||||
class UpdatesQuery(val driver: SqlDriver, val after: Long, val limit: Long) : ExecutableQuery<UpdatesView>(mapper) {
|
||||
override fun <R> execute(mapper: (SqlCursor) -> QueryResult<R>): QueryResult<R> {
|
||||
return driver.executeQuery(
|
||||
null,
|
||||
"""
|
||||
@ -82,6 +82,7 @@ class UpdatesQuery(val driver: SqlDriver, val after: Long, val limit: Long) : Qu
|
||||
ORDER BY datefetch DESC
|
||||
LIMIT :limit;
|
||||
""".trimIndent(),
|
||||
mapper,
|
||||
2,
|
||||
binders = {
|
||||
bindLong(1, after)
|
||||
|
@ -37,7 +37,7 @@ class CategoryRepositoryImpl(
|
||||
|
||||
// SY -->
|
||||
override suspend fun insert(category: Category): Long {
|
||||
return handler.awaitOne(true) {
|
||||
return handler.awaitOneExecutable(true) {
|
||||
categoriesQueries.insert(
|
||||
name = category.name,
|
||||
order = category.order,
|
||||
|
@ -2,7 +2,6 @@ package tachiyomi.data.chapter
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.lang.toLong
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
import tachiyomi.domain.chapter.model.Chapter
|
||||
@ -56,8 +55,8 @@ class ChapterRepositoryImpl(
|
||||
url = chapterUpdate.url,
|
||||
name = chapterUpdate.name,
|
||||
scanlator = chapterUpdate.scanlator,
|
||||
read = chapterUpdate.read?.toLong(),
|
||||
bookmark = chapterUpdate.bookmark?.toLong(),
|
||||
read = chapterUpdate.read,
|
||||
bookmark = chapterUpdate.bookmark,
|
||||
lastPageRead = chapterUpdate.lastPageRead,
|
||||
chapterNumber = chapterUpdate.chapterNumber?.toDouble(),
|
||||
sourceOrder = chapterUpdate.sourceOrder,
|
||||
|
@ -38,7 +38,7 @@ val mangaMapper: (Long, Long, String, String?, String?, String?, List<String>?,
|
||||
)
|
||||
}
|
||||
|
||||
val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long?, Long, Long, Long, Long, Long, Long, Long) -> LibraryManga =
|
||||
val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?, String, Long, String?, Boolean, Long?, Long?, Boolean, Long, Long, Long, Long, List<String>?, UpdateStrategy, Long, Long, Long?, Long, Double, Long, Long, Long, Double, Long) -> LibraryManga =
|
||||
{ id, source, url, artist, author, description, genre, title, status, thumbnailUrl, favorite, lastUpdate, nextUpdate, initialized, viewerFlags, chapterFlags, coverLastModified, dateAdded, filteredScanlators, updateStrategy, calculateInterval, lastModifiedAt, favoriteModifiedAt, totalCount, readCount, latestUpload, chapterFetchedAt, lastRead, bookmarkCount, category ->
|
||||
LibraryManga(
|
||||
manga = mangaMapper(
|
||||
@ -70,8 +70,8 @@ val libraryManga: (Long, Long, String, String?, String?, String?, List<String>?,
|
||||
),
|
||||
category = category,
|
||||
totalChapters = totalCount,
|
||||
readCount = readCount,
|
||||
bookmarkCount = bookmarkCount,
|
||||
readCount = readCount.toLong(),
|
||||
bookmarkCount = bookmarkCount.toLong(),
|
||||
latestUpload = latestUpload,
|
||||
chapterFetchedAt = chapterFetchedAt,
|
||||
lastRead = lastRead,
|
||||
@ -101,14 +101,14 @@ val libraryViewMapper: (LibraryView) -> LibraryManga = {
|
||||
updateStrategy = it.update_strategy,
|
||||
initialized = it.initialized,
|
||||
filteredScanlators = it.filtered_scanlators,
|
||||
calculateInterval = it.calculate_interval.toInt(),
|
||||
fetchInterval = it.calculate_interval.toInt(),
|
||||
lastModifiedAt = it.last_modified_at,
|
||||
favoriteModifiedAt = it.favorite_modified_at,
|
||||
),
|
||||
category = it.category,
|
||||
totalChapters = it.totalCount,
|
||||
readCount = it.readCount,
|
||||
bookmarkCount = it.bookmarkCount,
|
||||
readCount = it.readCount.toLong(),
|
||||
bookmarkCount = it.bookmarkCount.toLong(),
|
||||
latestUpload = it.latestUpload,
|
||||
chapterFetchedAt = it.chapterFetchedAt,
|
||||
lastRead = it.lastRead,
|
||||
|
@ -2,7 +2,6 @@ package tachiyomi.data.manga
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.lang.toLong
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
import tachiyomi.domain.manga.model.Manga
|
||||
@ -63,9 +62,9 @@ class MangaMergeRepositoryImpl(
|
||||
values.forEach { value ->
|
||||
mergedQueries.updateSettingsById(
|
||||
id = value.id,
|
||||
getChapterUpdates = value.getChapterUpdates?.toLong(),
|
||||
downloadChapters = value.downloadChapters?.toLong(),
|
||||
infoManga = value.isInfoManga?.toLong(),
|
||||
getChapterUpdates = value.getChapterUpdates,
|
||||
downloadChapters = value.downloadChapters,
|
||||
infoManga = value.isInfoManga,
|
||||
chapterPriority = value.chapterPriority?.toLong(),
|
||||
chapterSortMode = value.chapterSortMode?.toLong(),
|
||||
)
|
||||
@ -74,7 +73,7 @@ class MangaMergeRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun insert(reference: MergedMangaReference): Long? {
|
||||
return handler.awaitOneOrNull {
|
||||
return handler.awaitOneOrNullExecutable {
|
||||
mergedQueries.insert(
|
||||
infoManga = reference.isInfoManga,
|
||||
getChapterUpdates = reference.getChapterUpdates,
|
||||
|
@ -3,7 +3,6 @@ package tachiyomi.data.manga
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.lang.toLong
|
||||
import tachiyomi.core.util.system.logcat
|
||||
import tachiyomi.data.AndroidDatabaseHandler
|
||||
import tachiyomi.data.DatabaseHandler
|
||||
@ -40,7 +39,7 @@ class MangaRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun getLibraryManga(): List<LibraryManga> {
|
||||
return handler.awaitList { (handler as AndroidDatabaseHandler).getLibraryQuery() }.map(libraryViewMapper)
|
||||
return handler.awaitListExecutable { (handler as AndroidDatabaseHandler).getLibraryQuery() }.map(libraryViewMapper)
|
||||
// return handler.awaitList { libraryViewQueries.library(libraryManga) }
|
||||
}
|
||||
|
||||
@ -81,10 +80,10 @@ class MangaRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun insert(manga: Manga): Long? {
|
||||
return handler.awaitOneOrNull(inTransaction = true) {
|
||||
return handler.awaitOneOrNullExecutable(inTransaction = true) {
|
||||
// SY -->
|
||||
if (mangasQueries.getIdByUrlAndSource(manga.url, manga.source).executeAsOneOrNull() != null) {
|
||||
return@awaitOneOrNull mangasQueries.getIdByUrlAndSource(manga.url, manga.source)
|
||||
return@awaitOneOrNullExecutable mangasQueries.getIdByUrlAndSource(manga.url, manga.source)
|
||||
}
|
||||
// SY <--
|
||||
mangasQueries.insert(
|
||||
@ -148,11 +147,11 @@ class MangaRepositoryImpl(
|
||||
title = value.title,
|
||||
status = value.status,
|
||||
thumbnailUrl = value.thumbnailUrl,
|
||||
favorite = value.favorite?.toLong(),
|
||||
favorite = value.favorite,
|
||||
lastUpdate = value.lastUpdate,
|
||||
nextUpdate = value.nextUpdate,
|
||||
calculateInterval = value.fetchInterval?.toLong(),
|
||||
initialized = value.initialized?.toLong(),
|
||||
initialized = value.initialized,
|
||||
viewer = value.viewerFlags,
|
||||
chapterFlags = value.chapterFlags,
|
||||
coverLastModified = value.coverLastModified,
|
||||
@ -181,7 +180,7 @@ class MangaRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun getReadMangaNotInLibrary(): List<LibraryManga> {
|
||||
return handler.awaitList {
|
||||
return handler.awaitListExecutable {
|
||||
(handler as AndroidDatabaseHandler).getLibraryQuery("M.favorite = 0 AND C.readCount != 0")
|
||||
}.map(libraryViewMapper)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class FeedSavedSearchRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun insert(feedSavedSearch: FeedSavedSearch): Long {
|
||||
return handler.awaitOne(true) {
|
||||
return handler.awaitOneExecutable(true) {
|
||||
feed_saved_searchQueries.insert(
|
||||
feedSavedSearch.source,
|
||||
feedSavedSearch.savedSearch,
|
||||
|
@ -26,7 +26,7 @@ class SavedSearchRepositoryImpl(
|
||||
}
|
||||
|
||||
override suspend fun insert(savedSearch: SavedSearch): Long {
|
||||
return handler.awaitOne(true) {
|
||||
return handler.awaitOneExecutable(true) {
|
||||
saved_searchQueries.insert(
|
||||
savedSearch.source,
|
||||
savedSearch.name,
|
||||
|
@ -25,7 +25,7 @@ class UpdatesRepositoryImpl(
|
||||
return databaseHandler.subscribeToList {
|
||||
updatesViewQueries.getRecentUpdates(after, limit, updateWithRelationMapper)
|
||||
}.map {
|
||||
databaseHandler.awaitList { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after, limit) }
|
||||
databaseHandler.awaitListExecutable { (databaseHandler as AndroidDatabaseHandler).getUpdatesQuery(after, limit) }
|
||||
.map(updatesViewMapper)
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import kotlin.Long;
|
||||
import kotlin.collections.List;
|
||||
|
||||
CREATE TABLE categories(
|
||||
|
@ -1,3 +1,6 @@
|
||||
import kotlin.Boolean;
|
||||
import kotlin.Float;
|
||||
|
||||
CREATE TABLE chapters(
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
manga_id INTEGER NOT NULL,
|
||||
@ -9,9 +12,9 @@ CREATE TABLE chapters(
|
||||
last_page_read INTEGER NOT NULL,
|
||||
chapter_number REAL AS Float NOT NULL,
|
||||
source_order INTEGER NOT NULL,
|
||||
date_fetch INTEGER AS Long NOT NULL,
|
||||
date_upload INTEGER AS Long NOT NULL,
|
||||
last_modified_at INTEGER AS Long NOT NULL DEFAULT 0,
|
||||
date_fetch INTEGER NOT NULL,
|
||||
date_upload INTEGER NOT NULL,
|
||||
last_modified_at INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY(manga_id) REFERENCES mangas (_id)
|
||||
ON DELETE CASCADE
|
||||
);
|
||||
|
@ -1,3 +1,5 @@
|
||||
import kotlin.Boolean;
|
||||
|
||||
CREATE TABLE feed_saved_search (
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
source INTEGER NOT NULL,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import kotlin.Float;
|
||||
|
||||
CREATE TABLE manga_sync(
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
manga_id INTEGER NOT NULL,
|
||||
@ -10,8 +12,8 @@ CREATE TABLE manga_sync(
|
||||
status INTEGER NOT NULL,
|
||||
score REAL AS Float NOT NULL,
|
||||
remote_url TEXT NOT NULL,
|
||||
start_date INTEGER AS Long NOT NULL,
|
||||
finish_date INTEGER AS Long NOT NULL,
|
||||
start_date INTEGER NOT NULL,
|
||||
finish_date INTEGER NOT NULL,
|
||||
UNIQUE (manga_id, sync_id) ON CONFLICT REPLACE,
|
||||
FOREIGN KEY(manga_id) REFERENCES mangas (_id)
|
||||
ON DELETE CASCADE
|
||||
|
@ -1,6 +1,7 @@
|
||||
import eu.kanade.tachiyomi.source.model.UpdateStrategy;
|
||||
import java.lang.String;
|
||||
import kotlin.collections.List;
|
||||
import kotlin.Boolean;
|
||||
import kotlin.String;
|
||||
|
||||
CREATE TABLE mangas(
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
@ -14,18 +15,18 @@ CREATE TABLE mangas(
|
||||
status INTEGER NOT NULL,
|
||||
thumbnail_url TEXT,
|
||||
favorite INTEGER AS Boolean NOT NULL,
|
||||
last_update INTEGER AS Long,
|
||||
next_update INTEGER AS Long,
|
||||
last_update INTEGER,
|
||||
next_update INTEGER,
|
||||
initialized INTEGER AS Boolean NOT NULL,
|
||||
viewer INTEGER NOT NULL,
|
||||
chapter_flags INTEGER NOT NULL,
|
||||
cover_last_modified INTEGER AS Long NOT NULL,
|
||||
date_added INTEGER AS Long NOT NULL,
|
||||
cover_last_modified INTEGER NOT NULL,
|
||||
date_added INTEGER NOT NULL,
|
||||
filtered_scanlators TEXT AS List<String>,
|
||||
update_strategy INTEGER AS UpdateStrategy NOT NULL DEFAULT 0,
|
||||
calculate_interval INTEGER DEFAULT 0 NOT NULL,
|
||||
last_modified_at INTEGER AS Long NOT NULL DEFAULT 0,
|
||||
favorite_modified_at INTEGER AS Long
|
||||
last_modified_at INTEGER NOT NULL DEFAULT 0,
|
||||
favorite_modified_at INTEGER
|
||||
);
|
||||
|
||||
CREATE INDEX library_favorite_index ON mangas(favorite) WHERE favorite = 1;
|
||||
|
@ -2,7 +2,7 @@ CREATE TABLE mangas_categories(
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
manga_id INTEGER NOT NULL,
|
||||
category_id INTEGER NOT NULL,
|
||||
last_modified_at INTEGER AS Long NOT NULL DEFAULT 0,
|
||||
last_modified_at INTEGER NOT NULL DEFAULT 0,
|
||||
FOREIGN KEY(category_id) REFERENCES categories (_id)
|
||||
ON DELETE CASCADE,
|
||||
FOREIGN KEY(manga_id) REFERENCES mangas (_id)
|
||||
|
@ -1,3 +1,5 @@
|
||||
import kotlin.Boolean;
|
||||
|
||||
CREATE TABLE merged(
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
info_manga INTEGER AS Boolean NOT NULL,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import kotlin.Int;
|
||||
|
||||
CREATE TABLE search_metadata (
|
||||
manga_id INTEGER NOT NULL PRIMARY KEY,
|
||||
uploader TEXT,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import kotlin.Int;
|
||||
|
||||
CREATE TABLE search_tags (
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
manga_id INTEGER NOT NULL,
|
||||
|
@ -1,3 +1,5 @@
|
||||
import kotlin.Int;
|
||||
|
||||
CREATE TABLE search_titles (
|
||||
_id INTEGER NOT NULL PRIMARY KEY,
|
||||
manga_id INTEGER NOT NULL,
|
||||
|
@ -3,7 +3,7 @@ aboutlib_version = "10.8.3"
|
||||
okhttp_version = "5.0.0-alpha.11"
|
||||
shizuku_version = "12.2.0"
|
||||
sqlite = "2.3.1"
|
||||
sqldelight = "1.5.5"
|
||||
sqldelight = "2.0.0"
|
||||
leakcanary = "2.12"
|
||||
voyager = "1.0.0-rc06"
|
||||
richtext = "0.17.0"
|
||||
@ -80,10 +80,12 @@ shizuku-provider = { module = "dev.rikka.shizuku:provider", version.ref = "shizu
|
||||
leakcanary-android = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" }
|
||||
leakcanary-plumber = { module = "com.squareup.leakcanary:plumber-android", version.ref = "leakcanary" }
|
||||
|
||||
sqldelight-android-driver = { module = "com.squareup.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
sqldelight-coroutines = { module = "com.squareup.sqldelight:coroutines-extensions-jvm", version.ref = "sqldelight" }
|
||||
sqldelight-android-paging = { module = "com.squareup.sqldelight:android-paging3-extensions", version.ref = "sqldelight" }
|
||||
sqldelight-gradle = { module = "com.squareup.sqldelight:gradle-plugin", version.ref = "sqldelight" }
|
||||
sqldelight-android-driver = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
|
||||
sqldelight-coroutines = { module = "app.cash.sqldelight:coroutines-extensions-jvm", version.ref = "sqldelight" }
|
||||
sqldelight-android-paging = { module = "app.cash.sqldelight:androidx-paging3-extensions", version.ref = "sqldelight" }
|
||||
sqldelight-primitive-adapters = { module = "app.cash.sqldelight:primitive-adapters", version.ref = "sqldelight" }
|
||||
sqldelight-dialects-sql = { module = "app.cash.sqldelight:sqlite-3-38-dialect", version.ref = "sqldelight" }
|
||||
sqldelight-gradle = { module = "app.cash.sqldelight:gradle-plugin", version.ref = "sqldelight" }
|
||||
|
||||
junit = "org.junit.jupiter:junit-jupiter:5.10.0"
|
||||
kotest-assertions = "io.kotest:kotest-assertions-core:5.6.2"
|
||||
@ -102,6 +104,7 @@ js-engine = ["quickjs-android"]
|
||||
sqlite = ["sqlite-framework", "sqlite-ktx", "sqlite-android"]
|
||||
coil = ["coil-core", "coil-gif", "coil-compose"]
|
||||
shizuku = ["shizuku-api", "shizuku-provider"]
|
||||
sqldelight = ["sqldelight-android-driver", "sqldelight-coroutines", "sqldelight-android-paging", "sqldelight-primitive-adapters"]
|
||||
voyager = ["voyager-navigator", "voyager-tab-navigator", "voyager-transitions"]
|
||||
richtext = ["richtext-commonmark", "richtext-m3"]
|
||||
test = ["junit", "kotest-assertions", "mockk"]
|
@ -6,7 +6,7 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
android()
|
||||
androidTarget()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
|
@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
kotlin {
|
||||
android()
|
||||
androidTarget()
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
|
Loading…
x
Reference in New Issue
Block a user