fix: re-check mutation-block inside gesture coroutines

Stale drag-tick coroutines launched before the flip no-op at execution
time instead of moving the row after the reset.
This commit is contained in:
2026-09-04 14:59:59 +08:00
parent 7b63ee4377
commit b9baf61264
@@ -158,6 +158,7 @@ fun DictionaryListItem(
val target = if (rawOffset <= -swipeThresholdPx) -maxSwipePx else 0f val target = if (rawOffset <= -swipeThresholdPx) -maxSwipePx else 0f
rawOffset = target rawOffset = target
scope.launch { scope.launch {
if (isDeleteBlockedCurrent()) return@launch
offsetAnim.animateTo( offsetAnim.animateTo(
target, target,
animationSpec = spring(stiffness = Spring.StiffnessMedium) animationSpec = spring(stiffness = Spring.StiffnessMedium)
@@ -169,6 +170,7 @@ fun DictionaryListItem(
val target = if (rawOffset <= -swipeThresholdPx) -maxSwipePx else 0f val target = if (rawOffset <= -swipeThresholdPx) -maxSwipePx else 0f
rawOffset = target rawOffset = target
scope.launch { scope.launch {
if (isDeleteBlockedCurrent()) return@launch
offsetAnim.animateTo( offsetAnim.animateTo(
target, target,
animationSpec = spring(stiffness = Spring.StiffnessMedium) animationSpec = spring(stiffness = Spring.StiffnessMedium)
@@ -179,7 +181,10 @@ fun DictionaryListItem(
if (isDeleteBlockedCurrent()) return@detectHorizontalDragGestures if (isDeleteBlockedCurrent()) return@detectHorizontalDragGestures
val newOffset = (rawOffset + dragAmount).coerceIn(-maxSwipePx, 0f) val newOffset = (rawOffset + dragAmount).coerceIn(-maxSwipePx, 0f)
rawOffset = newOffset rawOffset = newOffset
scope.launch { offsetAnim.snapTo(newOffset) } scope.launch {
if (isDeleteBlockedCurrent()) return@launch
offsetAnim.snapTo(newOffset)
}
} }
) )
}, },