From b9baf612641f365f5c7bc88c8440483d13ee5314 Mon Sep 17 00:00:00 2001 From: OneWay Date: Fri, 4 Sep 2026 14:59:59 +0800 Subject: [PATCH] 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. --- .../research/ui/settings/components/DictionaryListItem.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/research/ui/settings/components/DictionaryListItem.kt b/app/src/main/java/com/example/research/ui/settings/components/DictionaryListItem.kt index 4a9d118..fa9bdd8 100644 --- a/app/src/main/java/com/example/research/ui/settings/components/DictionaryListItem.kt +++ b/app/src/main/java/com/example/research/ui/settings/components/DictionaryListItem.kt @@ -158,6 +158,7 @@ fun DictionaryListItem( val target = if (rawOffset <= -swipeThresholdPx) -maxSwipePx else 0f rawOffset = target scope.launch { + if (isDeleteBlockedCurrent()) return@launch offsetAnim.animateTo( target, animationSpec = spring(stiffness = Spring.StiffnessMedium) @@ -169,6 +170,7 @@ fun DictionaryListItem( val target = if (rawOffset <= -swipeThresholdPx) -maxSwipePx else 0f rawOffset = target scope.launch { + if (isDeleteBlockedCurrent()) return@launch offsetAnim.animateTo( target, animationSpec = spring(stiffness = Spring.StiffnessMedium) @@ -179,7 +181,10 @@ fun DictionaryListItem( if (isDeleteBlockedCurrent()) return@detectHorizontalDragGestures val newOffset = (rawOffset + dragAmount).coerceIn(-maxSwipePx, 0f) rawOffset = newOffset - scope.launch { offsetAnim.snapTo(newOffset) } + scope.launch { + if (isDeleteBlockedCurrent()) return@launch + offsetAnim.snapTo(newOffset) + } } ) },