mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Split MatrixRoom into BaseRoom and JoinedRoom (#4561)
`JoinedRoom` will now contain both a mandatory live timeline reference and all the functionality associated to it. `BaseRoom` on the other hand will contain only functionality that's shared for both joined and not joined rooms. `NotJoinedRoom` is a wrapper around `RoomPreviewInfo` data and a possible local `BaseRoom`, if it exists. The `RustRoomFactory` cache is now gone since the persistent event cache should have the same effect.
This commit is contained in:
committed by
GitHub
parent
91cb84ce8d
commit
619aa6f2de
+2
-2
@@ -16,12 +16,12 @@ import io.element.android.features.call.api.CurrentCall
|
||||
import io.element.android.features.call.api.CurrentCallService
|
||||
import io.element.android.features.roomcall.api.RoomCallState
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
||||
import io.element.android.libraries.matrix.ui.room.canCall
|
||||
import javax.inject.Inject
|
||||
|
||||
class RoomCallStatePresenter @Inject constructor(
|
||||
private val room: MatrixRoom,
|
||||
private val room: JoinedRoom,
|
||||
private val currentCallService: CurrentCallService,
|
||||
) : Presenter<RoomCallState> {
|
||||
@Composable
|
||||
|
||||
+33
-20
@@ -12,8 +12,9 @@ import io.element.android.features.call.api.CurrentCall
|
||||
import io.element.android.features.call.api.CurrentCallService
|
||||
import io.element.android.features.call.test.FakeCurrentCallService
|
||||
import io.element.android.features.roomcall.api.RoomCallState
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.JoinedRoom
|
||||
import io.element.android.libraries.matrix.test.room.FakeBaseRoom
|
||||
import io.element.android.libraries.matrix.test.room.FakeJoinedRoom
|
||||
import io.element.android.libraries.matrix.test.room.aRoomInfo
|
||||
import io.element.android.tests.testutils.test
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
@@ -23,10 +24,12 @@ import org.junit.Test
|
||||
class RoomCallStatePresenterTest {
|
||||
@Test
|
||||
fun `present - initial state`() = runTest {
|
||||
val room = FakeMatrixRoom(
|
||||
canUserJoinCallResult = { Result.success(false) },
|
||||
val room = FakeJoinedRoom(
|
||||
baseRoom = FakeBaseRoom(
|
||||
canUserJoinCallResult = { Result.success(false) },
|
||||
)
|
||||
)
|
||||
val presenter = createRoomCallStatePresenter(matrixRoom = room)
|
||||
val presenter = createRoomCallStatePresenter(joinedRoom = room)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState).isEqualTo(
|
||||
@@ -39,10 +42,12 @@ class RoomCallStatePresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - initial state - user can join call`() = runTest {
|
||||
val room = FakeMatrixRoom(
|
||||
canUserJoinCallResult = { Result.success(true) },
|
||||
val room = FakeJoinedRoom(
|
||||
baseRoom = FakeBaseRoom(
|
||||
canUserJoinCallResult = { Result.success(true) },
|
||||
)
|
||||
)
|
||||
val presenter = createRoomCallStatePresenter(matrixRoom = room)
|
||||
val presenter = createRoomCallStatePresenter(joinedRoom = room)
|
||||
presenter.test {
|
||||
skipItems(1)
|
||||
val initialState = awaitItem()
|
||||
@@ -56,11 +61,13 @@ class RoomCallStatePresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - call is disabled if user cannot join it even if there is an ongoing call`() = runTest {
|
||||
val room = FakeMatrixRoom(
|
||||
canUserJoinCallResult = { Result.success(false) },
|
||||
initialRoomInfo = aRoomInfo(hasRoomCall = true),
|
||||
val room = FakeJoinedRoom(
|
||||
baseRoom = FakeBaseRoom(
|
||||
canUserJoinCallResult = { Result.success(false) },
|
||||
initialRoomInfo = aRoomInfo(hasRoomCall = true),
|
||||
)
|
||||
)
|
||||
val presenter = createRoomCallStatePresenter(matrixRoom = room)
|
||||
val presenter = createRoomCallStatePresenter(joinedRoom = room)
|
||||
presenter.test {
|
||||
assertThat(awaitItem()).isEqualTo(
|
||||
RoomCallState.OnGoing(
|
||||
@@ -74,7 +81,8 @@ class RoomCallStatePresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - user has joined the call on another session`() = runTest {
|
||||
val room = FakeMatrixRoom(
|
||||
val room = FakeJoinedRoom(
|
||||
baseRoom = FakeBaseRoom(
|
||||
canUserJoinCallResult = { Result.success(true) },
|
||||
).apply {
|
||||
givenRoomInfo(
|
||||
@@ -84,7 +92,8 @@ class RoomCallStatePresenterTest {
|
||||
)
|
||||
)
|
||||
}
|
||||
val presenter = createRoomCallStatePresenter(matrixRoom = room)
|
||||
)
|
||||
val presenter = createRoomCallStatePresenter(joinedRoom = room)
|
||||
presenter.test {
|
||||
skipItems(1)
|
||||
assertThat(awaitItem()).isEqualTo(
|
||||
@@ -99,7 +108,8 @@ class RoomCallStatePresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - user has joined the call locally`() = runTest {
|
||||
val room = FakeMatrixRoom(
|
||||
val room = FakeJoinedRoom(
|
||||
baseRoom = FakeBaseRoom(
|
||||
canUserJoinCallResult = { Result.success(true) },
|
||||
).apply {
|
||||
givenRoomInfo(
|
||||
@@ -109,8 +119,9 @@ class RoomCallStatePresenterTest {
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
val presenter = createRoomCallStatePresenter(
|
||||
matrixRoom = room,
|
||||
joinedRoom = room,
|
||||
currentCallService = FakeCurrentCallService(MutableStateFlow(CurrentCall.RoomCall(room.roomId))),
|
||||
)
|
||||
presenter.test {
|
||||
@@ -127,7 +138,8 @@ class RoomCallStatePresenterTest {
|
||||
|
||||
@Test
|
||||
fun `present - user leaves the call`() = runTest {
|
||||
val room = FakeMatrixRoom(
|
||||
val room = FakeJoinedRoom(
|
||||
baseRoom = FakeBaseRoom(
|
||||
canUserJoinCallResult = { Result.success(true) },
|
||||
).apply {
|
||||
givenRoomInfo(
|
||||
@@ -137,10 +149,11 @@ class RoomCallStatePresenterTest {
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
val currentCall = MutableStateFlow<CurrentCall>(CurrentCall.RoomCall(room.roomId))
|
||||
val currentCallService = FakeCurrentCallService(currentCall = currentCall)
|
||||
val presenter = createRoomCallStatePresenter(
|
||||
matrixRoom = room,
|
||||
joinedRoom = room,
|
||||
currentCallService = currentCallService
|
||||
)
|
||||
presenter.test {
|
||||
@@ -188,11 +201,11 @@ class RoomCallStatePresenterTest {
|
||||
}
|
||||
|
||||
private fun createRoomCallStatePresenter(
|
||||
matrixRoom: MatrixRoom,
|
||||
joinedRoom: JoinedRoom,
|
||||
currentCallService: CurrentCallService = FakeCurrentCallService(),
|
||||
): RoomCallStatePresenter {
|
||||
return RoomCallStatePresenter(
|
||||
room = matrixRoom,
|
||||
room = joinedRoom,
|
||||
currentCallService = currentCallService,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user