mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
improvements in Beheviour Context
This commit is contained in:
parent
be027efc43
commit
562e8c7429
@ -2,6 +2,9 @@
|
||||
|
||||
## 1.1.4
|
||||
|
||||
* `Behaviour Builder`:
|
||||
* Improvements in updates passing inside of subcontexts
|
||||
|
||||
## 1.1.3
|
||||
|
||||
* `Behaviour Builder with FSM`:
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user