No need to use a dispatcher.

Fix issue detected by sonar: `Remove this dispatcher. It is pointless when used with only suspending functions.`
This commit is contained in:
Benoit Marty 2023-02-01 15:08:31 +01:00
parent f52b8efa87
commit eafac31ccc
2 changed files with 3 additions and 5 deletions

View file

@ -87,7 +87,7 @@ internal class RustMatrixClient internal constructor(
.addView(slidingSyncView)
.build()
private val slidingSyncObserverProxy = SlidingSyncObserverProxy(coroutineScope, dispatchers)
private val slidingSyncObserverProxy = SlidingSyncObserverProxy(coroutineScope)
private val roomSummaryDataSource: RustRoomSummaryDataSource =
RustRoomSummaryDataSource(
slidingSyncObserverProxy.updateSummaryFlow,

View file

@ -16,7 +16,6 @@
package io.element.android.libraries.matrix.sync
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
@ -30,7 +29,6 @@ private const val BUFFER_SIZE = 64
class SlidingSyncObserverProxy(
private val coroutineScope: CoroutineScope,
private val coroutineDispatchers: CoroutineDispatchers
) : SlidingSyncObserver {
private val updateSummaryMutableFlow =
@ -39,8 +37,8 @@ class SlidingSyncObserverProxy(
override fun didReceiveSyncUpdate(summary: UpdateSummary) {
if (summary.rooms.isEmpty()) return
coroutineScope.launch(coroutineDispatchers.io) {
updateSummaryMutableFlow.emit(summary)
coroutineScope.launch {
updateSummaryMutableFlow.tryEmit(summary)
}
}
}