Fix issues on JoinedRoom / BaseRoom (#4724)
* Import type * Add test to cover an existing issue. roomCoroutineScope is not cancelled when the class is destroyed * Cancel roomCoroutineScope when the class is destroyed * Move `isOneToOne` to BaseRoom, we do not need a JoinedRoom for it. * Let `roomInfoFlow` be implemented by RustBaseRoom. It should fix a few issues where we rely on the room info to be live, and it was not the case on RustBaseRoom. * Add more assertions. The test would fail anyway if roomCoroutineScope was still active, but it's more explicit with these assertions.
This commit is contained in:
parent
882a690a6c
commit
0817da9691
6 changed files with 77 additions and 26 deletions
|
|
@ -55,6 +55,12 @@ interface BaseRoom : Closeable {
|
|||
*/
|
||||
fun info(): RoomInfo = roomInfoFlow.value
|
||||
|
||||
/**
|
||||
* A one-to-one is a room with exactly 2 members.
|
||||
* See [the Matrix spec](https://spec.matrix.org/latest/client-server-api/#default-underride-rules).
|
||||
*/
|
||||
val isOneToOne: Boolean get() = info().activeMembersCount == 2L
|
||||
|
||||
/**
|
||||
* Try to load the room members and update the membersFlow.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -50,12 +50,6 @@ interface JoinedRoom : BaseRoom {
|
|||
*/
|
||||
val knockRequestsFlow: Flow<List<KnockRequest>>
|
||||
|
||||
/**
|
||||
* A one-to-one is a room with exactly 2 members.
|
||||
* See [the Matrix spec](https://spec.matrix.org/latest/client-server-api/#default-underride-rules).
|
||||
*/
|
||||
val isOneToOne: Boolean get() = info().activeMembersCount == 2L
|
||||
|
||||
/**
|
||||
* The live timeline of the room. Must be used to send Event to a room.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue