mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-16 13:48:09 -07:00
Keep category orders unique while reordering
Reordering first moves every category to a temporary negative position, then assigns the final ones, so two categories never share a position mid-update. Deleting a category no longer renumbers the system category.
This commit is contained in:
@@ -77,6 +77,9 @@ class CategoryRepositoryImpl(
|
||||
|
||||
override suspend fun updateAllOrders(orderedIds: List<Long>) {
|
||||
database.transaction {
|
||||
orderedIds.forEachIndexed { index, categoryId ->
|
||||
database.categoriesQueries.updateOrder(order = -index - 2L, categoryId = categoryId)
|
||||
}
|
||||
orderedIds.forEachIndexed { index, categoryId ->
|
||||
database.categoriesQueries.updateOrder(order = index.toLong(), categoryId = categoryId)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user