From 1d2ae121964d80d68b1ae292548f7a061999ac4f Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 13 May 2022 14:56:17 +0100 Subject: [PATCH] Log events properly in EventChannelImpl --- .../src/commonMain/kotlin/event/EventChannelImpl.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mirai-core/src/commonMain/kotlin/event/EventChannelImpl.kt b/mirai-core/src/commonMain/kotlin/event/EventChannelImpl.kt index 913d1fa34..6195b318a 100644 --- a/mirai-core/src/commonMain/kotlin/event/EventChannelImpl.kt +++ b/mirai-core/src/commonMain/kotlin/event/EventChannelImpl.kt @@ -37,7 +37,7 @@ internal annotation class DangerousEventChannelImplConstructor internal open class EventChannelImpl @DangerousEventChannelImplConstructor constructor( baseEventClass: KClass, defaultCoroutineContext: CoroutineContext = EmptyCoroutineContext ) : EventChannel(baseEventClass, defaultCoroutineContext) { - val eventListeners = EventListeners() + private val eventListeners = EventListeners() // drop any unsubscribed events private val flow = MutableSharedFlow(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST) @@ -48,6 +48,7 @@ internal open class EventChannelImpl @DangerousEventChannelImplConstr suspend fun callListeners(event: Event) { event as AbstractEvent + logEvent(event) eventListeners.callListeners(event) flow.emit(event) } @@ -86,10 +87,7 @@ internal open class EventChannelImpl @DangerousEventChannelImplConstr } event.broadCastLock.withLock { event._intercepted = false - @Suppress("DEPRECATION") - if (EventDisabled) return@withLock - logEvent(event) - eventListeners.callListeners(event) + callListeners(event) } return event