TP-39967 | debounce fix (#169)

This commit is contained in:
Maila Rajanikanth
2023-09-05 13:03:33 +05:30
committed by GitHub
parent 3c8fc105bd
commit aae8a2df69

View File

@@ -216,11 +216,18 @@ fun Modifier.customClickable(
MutableSharedFlow<Unit>()
)
}
var lastClickEvent: Long by remember { mutableStateOf(0) }
LaunchedEffect(clickEvents) {
clickEvents.debounce(property.debounceTime.orZero()).collect {
onClick()
clickEvents.collect {
val now = System.currentTimeMillis()
if (now - lastClickEvent >= property.debounceTime.orZero()) {
onClick()
lastClickEvent = now
}
}
}
clickable(
indication = getInteractionType(interaction = property.interaction),
interactionSource = remember { MutableInteractionSource() }) {