mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 02:34:39 +00:00
refactor(db): Migrate last category queries (that can be migrated) to SQLDelight
This commit is contained in:
parent
663360c283
commit
a4a7f8fb6d
2 changed files with 4 additions and 6 deletions
|
@ -18,8 +18,4 @@ interface CategoryQueries : DbProvider {
|
|||
)
|
||||
.prepare()
|
||||
|
||||
fun insertCategory(category: Category) = db.put().`object`(category).prepare()
|
||||
|
||||
fun insertCategories(categories: List<Category>) = db.put().objects(categories).prepare()
|
||||
|
||||
}
|
||||
|
|
|
@ -285,10 +285,12 @@ class LibraryPresenter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun reorderCategories(categories: List<Category>) {
|
||||
private suspend fun reorderCategories(categories: List<Category>) {
|
||||
val sortedCategories = categories.sortedBy { it.order }
|
||||
sortedCategories.forEachIndexed { i, category -> category.order = i }
|
||||
db.insertCategories(sortedCategories).executeAsBlocking()
|
||||
updateCategories.await(
|
||||
sortedCategories.map { CategoryUpdate(id = it.id!!.toLong(), order = it.order.toLong()) }
|
||||
)
|
||||
}
|
||||
|
||||
fun switchSection(order: Int) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue