mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2025-09-02 14:49:47 +00:00
improvements in Beheviour Context
This commit is contained in:
@@ -73,7 +73,10 @@ class DefaultBehaviourContext(
|
||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
||||
if (upstreamUpdatesFlow != null) {
|
||||
(it + upstreamUpdatesFlow).distinctUntilChanged { old, new -> old.updateId == new.updateId }
|
||||
var lastHandledUpdate = -1L
|
||||
(it + upstreamUpdatesFlow).filter {
|
||||
(it.updateId > lastHandledUpdate).also { passed -> if (passed) { lastHandledUpdate = it.updateId } }
|
||||
}
|
||||
} else {
|
||||
it
|
||||
}
|
||||
|
Reference in New Issue
Block a user