diff --git a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt index cbec86bf52..cf9850f52b 100644 --- a/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt +++ b/tgbotapi.behaviour_builder.fsm/src/commonMain/kotlin/dev/inmo/tgbotapi/extensions/behaviour_builder/BehaviourContextWithFSM.kt @@ -197,7 +197,7 @@ class DefaultBehaviourContextWithFSM( statesJobsMutex.withLock { runCatchingSafely { statesJobs.remove(old) ?.cancel() } runCatchingSafely { statesJobs.remove(new) ?.cancel() } - statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(it) } + statesJobs[new] = launch { statePerformer(new) }.apply { enableRemoveOnCompletion(new) } } if (old.context != new.context) { updatesFlows.remove(old.context)