Build fixes and minor improvements

This commit is contained in:
Jobobby04 2022-06-18 19:27:26 -04:00
parent a5fe4e1a44
commit cd4b6a0c27
8 changed files with 42 additions and 8 deletions

View File

@ -2,11 +2,14 @@ package eu.kanade.data.category
import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.Category
val categoryMapper: (Long, String, Long, Long) -> Category = { id, name, order, flags -> val categoryMapper: (Long, String, Long, Long, List<Long>) -> Category = { id, name, order, flags, mangaOrder ->
Category( Category(
id = id, id = id,
name = name, name = name,
order = order, order = order,
flags = flags, flags = flags,
// SY -->
mangaOrder = mangaOrder,
// SY <--
) )
} }

View File

@ -1,6 +1,7 @@
package eu.kanade.data.category package eu.kanade.data.category
import eu.kanade.data.DatabaseHandler import eu.kanade.data.DatabaseHandler
import eu.kanade.data.listOfLongsAdapter
import eu.kanade.domain.category.model.Category import eu.kanade.domain.category.model.Category
import eu.kanade.domain.category.model.CategoryUpdate import eu.kanade.domain.category.model.CategoryUpdate
import eu.kanade.domain.category.repository.CategoryRepository import eu.kanade.domain.category.repository.CategoryRepository
@ -23,6 +24,9 @@ class CategoryRepositoryImpl(
name = name, name = name,
order = order, order = order,
flags = 0L, flags = 0L,
// SY -->
mangaOrder = emptyList(),
// SY <--
) )
} }
} }
@ -36,6 +40,9 @@ class CategoryRepositoryImpl(
order = payload.order, order = payload.order,
flags = payload.flags, flags = payload.flags,
categoryId = payload.id, categoryId = payload.id,
// SY -->
mangaOrder = payload.mangaOrder?.let(listOfLongsAdapter::encode),
// SY <--
) )
} }
} }

View File

@ -7,4 +7,7 @@ data class Category(
val name: String, val name: String,
val order: Long, val order: Long,
val flags: Long, val flags: Long,
// SY -->
val mangaOrder: List<Long>,
// SY <--
) : Serializable ) : Serializable

View File

@ -5,4 +5,7 @@ data class CategoryUpdate(
val name: String? = null, val name: String? = null,
val order: Long? = null, val order: Long? = null,
val flags: Long? = null, val flags: Long? = null,
// SY -->
val mangaOrder: List<Long>? = null,
// SY <--
) )

View File

@ -47,7 +47,9 @@ fun MigrateSourceScreen(
presenter: MigrationSourcesPresenter, presenter: MigrationSourcesPresenter,
onClickItem: (Source) -> Unit, onClickItem: (Source) -> Unit,
onLongClickItem: (Source) -> Unit, onLongClickItem: (Source) -> Unit,
// SY -->
onClickAll: (Source) -> Unit, onClickAll: (Source) -> Unit,
// SY <--
) { ) {
val state by presenter.state.collectAsState() val state by presenter.state.collectAsState()
when (state) { when (state) {
@ -59,7 +61,9 @@ fun MigrateSourceScreen(
list = (state as MigrateSourceState.Success).sources, list = (state as MigrateSourceState.Success).sources,
onClickItem = onClickItem, onClickItem = onClickItem,
onLongClickItem = onLongClickItem, onLongClickItem = onLongClickItem,
// SY -->
onClickAll = onClickAll, onClickAll = onClickAll,
// SY <--
) )
} }
} }
@ -70,7 +74,9 @@ fun MigrateSourceList(
list: List<Pair<Source, Long>>, list: List<Pair<Source, Long>>,
onClickItem: (Source) -> Unit, onClickItem: (Source) -> Unit,
onLongClickItem: (Source) -> Unit, onLongClickItem: (Source) -> Unit,
// SY -->
onClickAll: (Source) -> Unit, onClickAll: (Source) -> Unit,
// SY <--
) { ) {
if (list.isEmpty()) { if (list.isEmpty()) {
EmptyScreen(textResource = R.string.information_empty_library) EmptyScreen(textResource = R.string.information_empty_library)
@ -103,7 +109,9 @@ fun MigrateSourceList(
count = count, count = count,
onClickItem = { onClickItem(source) }, onClickItem = { onClickItem(source) },
onLongClickItem = { onLongClickItem(source) }, onLongClickItem = { onLongClickItem(source) },
// SY -->
onClickAll = { onClickAll(source) }, onClickAll = { onClickAll(source) },
// SY <--
) )
} }
} }
@ -116,7 +124,9 @@ fun MigrateSourceItem(
count: Long, count: Long,
onClickItem: () -> Unit, onClickItem: () -> Unit,
onLongClickItem: () -> Unit, onLongClickItem: () -> Unit,
// SY -->
onClickAll: () -> Unit, onClickAll: () -> Unit,
// SY <--
) { ) {
BaseSourceItem( BaseSourceItem(
modifier = modifier, modifier = modifier,

View File

@ -30,4 +30,6 @@ interface CategoryQueries : DbProvider {
.prepare() .prepare()
fun insertCategory(category: Category) = db.put().`object`(category).prepare() fun insertCategory(category: Category) = db.put().`object`(category).prepare()
fun insertCategories(categories: List<Category>) = db.put().objects(categories).prepare()
} }

View File

@ -18,7 +18,6 @@ import eu.kanade.tachiyomi.source.model.toSManga
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
import eu.kanade.tachiyomi.util.lang.launchIO import eu.kanade.tachiyomi.util.lang.launchIO
import eu.kanade.tachiyomi.util.lang.runAsObservable import eu.kanade.tachiyomi.util.lang.runAsObservable
import eu.kanade.tachiyomi.util.lang.withIOContext
import eu.kanade.tachiyomi.util.system.logcat import eu.kanade.tachiyomi.util.system.logcat
import exh.savedsearches.models.FeedSavedSearch import exh.savedsearches.models.FeedSavedSearch
import exh.savedsearches.models.SavedSearch import exh.savedsearches.models.SavedSearch
@ -83,9 +82,7 @@ open class FeedPresenter(
} }
suspend fun hasTooManyFeeds(): Boolean { suspend fun hasTooManyFeeds(): Boolean {
return withIOContext { return database.awaitOne { feed_saved_searchQueries.countGlobal() } > 10
database.awaitList { feed_saved_searchQueries.selectAllGlobal() }.size > 10
}
} }
fun getEnabledSources(): List<CatalogueSource> { fun getEnabledSources(): List<CatalogueSource> {
@ -100,9 +97,7 @@ open class FeedPresenter(
} }
suspend fun getSourceSavedSearches(source: CatalogueSource): List<SavedSearch> { suspend fun getSourceSavedSearches(source: CatalogueSource): List<SavedSearch> {
return withIOContext { return database.awaitList { saved_searchQueries.selectBySource(source.id, savedSearchMapper) }
database.awaitList { saved_searchQueries.selectBySource(source.id, savedSearchMapper) }
}
} }
fun createFeed(source: CatalogueSource, savedSearch: SavedSearch?) { fun createFeed(source: CatalogueSource, savedSearch: SavedSearch?) {

View File

@ -12,6 +12,9 @@ CREATE INDEX feed_saved_search_saved_search_index ON feed_saved_search(saved_sea
selectAllGlobal: selectAllGlobal:
SELECT * FROM feed_saved_search WHERE global = 1; SELECT * FROM feed_saved_search WHERE global = 1;
countGlobal:
SELECT count(*) FROM feed_saved_search WHERE global = 1;
selectBySource: selectBySource:
SELECT * FROM feed_saved_search WHERE source = ? AND global = 0; SELECT * FROM feed_saved_search WHERE source = ? AND global = 0;
@ -39,3 +42,11 @@ FROM (
) AS M ) AS M
JOIN saved_search JOIN saved_search
ON saved_search._id = M.saved_search; ON saved_search._id = M.saved_search;
countSourceFeedSavedSearch:
SELECT count(*)
FROM (
SELECT saved_search FROM feed_saved_search WHERE global = 0 AND source = ?
) AS M
JOIN saved_search
ON saved_search._id = M.saved_search;