Throttle OpenTask sync requests

pull/3279/head
Alex Baker 11 months ago
parent 4c3ba4cb72
commit fb72f10153

@ -7,16 +7,12 @@ class Debouncer(private val tag: String, private val block: suspend (Boolean) ->
private var count = 0 private var count = 0
suspend fun sync(immediate: Boolean) { suspend fun sync(immediate: Boolean) {
if (immediate) { val thisCount = ++count
block(true) delay(1000)
if (thisCount == count) {
block(immediate)
} else { } else {
val thisCount = ++count Timber.v("debouncing $tag")
delay(1000)
if (thisCount == count) {
block(false)
} else {
Timber.v("debouncing $tag")
}
} }
} }
} }

Loading…
Cancel
Save