MatrixRoom API refinement (#719)

- `syncUpdateFlow` becomes a `val` and always returns the same instance of the underlying `StateFlow` instead of different `Flow` instances to allow consumers not to remember the `Flow` and not to specify an unneeded initial value.
- `timeline` becomes a `val` as it already always returns the same instance.
- Amends calling code accordingly
- Removes a few unneeded `val`s in `RustMatrixClient
- Fixes a small bug in `MessagesPresenter` that allowed to sometime show a newly created room's name as "Empty room" (changes `LaunchedEffect(syncUpdateFlow)` to `LaunchedEffect(syncUpdateFlow.value)`)
This commit is contained in:
Marco Romano 2023-06-29 10:48:55 +02:00 committed by GitHub
parent 91060c76a7
commit 354374ed49
8 changed files with 23 additions and 34 deletions

View file

@ -34,9 +34,8 @@ import io.element.android.libraries.matrix.test.A_ROOM_ID
import io.element.android.libraries.matrix.test.A_SESSION_ID
import io.element.android.libraries.matrix.test.timeline.FakeMatrixTimeline
import io.element.android.tests.testutils.simulateLongTask
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.StateFlow
import java.io.File
class FakeMatrixRoom(
@ -126,13 +125,9 @@ class FakeMatrixRoom(
updateMembersResult
}
override fun syncUpdateFlow(): Flow<Long> {
return emptyFlow()
}
override val syncUpdateFlow: StateFlow<Long> = MutableStateFlow(0L)
override fun timeline(): MatrixTimeline {
return matrixTimeline
}
override val timeline: MatrixTimeline = matrixTimeline
override fun open(): Result<Unit> {
return Result.success(Unit)