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 059c5dc003
commit 427716b1a7
2 changed files with 3 additions and 5 deletions

View file

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

View file

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