Avoid launching coroutine for nothing.

This commit is contained in:
Benoit Marty 2023-01-03 11:55:32 +01:00
parent 56986c3a77
commit 837590104d
2 changed files with 7 additions and 7 deletions

View File

@ -42,14 +42,12 @@ internal class StreamEventsManager @Inject constructor() {
listeners.remove(listener)
}
fun dispatchLiveEventReceived(event: Event, roomId: String, initialSync: Boolean) {
fun dispatchLiveEventReceived(event: Event, roomId: String) {
Timber.v("## dispatchLiveEventReceived ${event.eventId}")
coroutineScope.launch {
if (!initialSync) {
listeners.forEach {
tryOrNull {
it.onLiveEvent(roomId, event)
}
listeners.forEach {
tryOrNull {
it.onLiveEvent(roomId, event)
}
}
}

View File

@ -423,7 +423,9 @@ internal class RoomSyncHandler @Inject constructor(
val isInitialSync = insertType == EventInsertType.INITIAL_SYNC
eventIds.add(event.eventId)
liveEventService.get().dispatchLiveEventReceived(event, roomId, isInitialSync)
if (!isInitialSync) {
liveEventService.get().dispatchLiveEventReceived(event, roomId)
}
if (event.isEncrypted() && !isInitialSync) {
try {