perf: longPressDraggableHandle

This commit is contained in:
lisonge 2024-02-15 19:38:39 +08:00
parent 5e58901aa6
commit 2eb76cd1cd

View File

@ -293,7 +293,7 @@ fun useSubsManagePage(): ScaffoldExt {
) )
Card( Card(
modifier = Modifier modifier = Modifier
.draggableHandle(onDragStopped = { .longPressDraggableHandle(onDragStopped = {
val changeItems = mutableListOf<SubsItem>() val changeItems = mutableListOf<SubsItem>()
orderSubItems.forEachIndexed { i, subsItem -> orderSubItems.forEachIndexed { i, subsItem ->
if (subItems[i] != subsItem) { if (subItems[i] != subsItem) {
@ -305,8 +305,10 @@ fun useSubsManagePage(): ScaffoldExt {
} }
} }
if (orderSubItems.isNotEmpty()) { if (orderSubItems.isNotEmpty()) {
vm.viewModelScope.launchTry {
DbSet.subsItemDao.update(*changeItems.toTypedArray()) DbSet.subsItemDao.update(*changeItems.toTypedArray())
} }
}
}) })
.shadow(elevation) .shadow(elevation)
.animateItemPlacement() .animateItemPlacement()