Skip to content

Commit

Permalink
Avoid launching coroutine for nothing.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmarty committed Jan 3, 2023
1 parent 56986c3 commit 8375901
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8375901

Please sign in to comment.