mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2026-10-26 06:27:00 +00:00
improvements in Beheviour Context
This commit is contained in:
1 parent
be027efc43
commit
562e8c7429
2 files changed
+7
-1
No files matched your search
+4
-1
@@ -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