From 69d36c5c1b04960e5b93c40f713c0b72c6bb7bcb Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 11 May 2022 11:04:21 +0600 Subject: [PATCH] a little refactor --- CHANGELOG.md | 2 ++ .../tgbotapi/extensions/behaviour_builder/BehaviourContext.kt | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba7cb5ee0e..5b78993518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,8 @@ __All the `tgbotapi.extensions.*` packages have been removed__ * `SimpleFilter` now is a `fun interface` instead of just callback (fix of [#546](https://github.com/InsanusMokrassar/TelegramBotAPI/issues/546)) * New extension `BehaviourContext#createSubContext`. It uses separated `AccumulatorFlow` and will retrieve updates by itself * New extension `BehaviourContext#doInContext` + * Extension `BehaviourContext#doInSubContextWithUpdatesFilter` has been renamed to `BehaviourContext#createSubContextAndDoWithUpdatesFilter` + * Extension `BehaviourContext#doInSubContext` has been deprecated * `BehaviourContextWithFSM`: * `launchStateHandling` lost its parameter `contextUpdatesFlow: Flow` * `handleState` of `BehaviourContextWithFSM` now will get/create sub context for the state and launch handling in it diff --git a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt index 00929f64b4..b1c6d837b2 100644 --- a/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt +++ b/tgbotapi.behaviour_builder/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContext.kt @@ -116,7 +116,7 @@ inline fun BehaviourContext( fun BC.createSubContext( scope: CoroutineScope = LinkedSupervisorScope(), triggersHolder: TriggersHolder = this.triggersHolder, - updatesUpstreamFlow: Flow = allUpdatesFlow.accumulatorFlow(scope), + updatesUpstreamFlow: Flow = allUpdatesFlow, updatesFilter: CustomBehaviourContextAndTypeReceiver? = null, ) = copy( scope = scope, @@ -154,7 +154,7 @@ suspend fun BC.doInContext( suspend fun BC.createSubContextAndDoWithUpdatesFilter( scope: CoroutineScope = LinkedSupervisorScope(), triggersHolder: TriggersHolder = this.triggersHolder, - updatesUpstreamFlow: Flow = allUpdatesFlow.accumulatorFlow(scope), + updatesUpstreamFlow: Flow = allUpdatesFlow, updatesFilter: CustomBehaviourContextAndTypeReceiver? = null, stopOnCompletion: Boolean = true, behaviourContextReceiver: CustomBehaviourContextReceiver