mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-11-22 08:13:47 +00:00
improvements in Beheviour Context
This commit is contained in:
parent
be027efc43
commit
562e8c7429
@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
## 1.1.4
|
## 1.1.4
|
||||||
|
|
||||||
|
* `Behaviour Builder`:
|
||||||
|
* Improvements in updates passing inside of subcontexts
|
||||||
|
|
||||||
## 1.1.3
|
## 1.1.3
|
||||||
|
|
||||||
* `Behaviour Builder with FSM`:
|
* `Behaviour Builder with FSM`:
|
||||||
|
@ -73,7 +73,10 @@ class DefaultBehaviourContext(
|
|||||||
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
private val additionalUpdatesSharedFlow = MutableSharedFlow<Update>(0, broadcastChannelsSize, onBufferOverflow)
|
||||||
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
override val allUpdatesFlow: Flow<Update> = (additionalUpdatesSharedFlow.asSharedFlow()).let {
|
||||||
if (upstreamUpdatesFlow != null) {
|
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 {
|
} else {
|
||||||
it
|
it
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user