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:
parent
91cb84ce8d
commit
619aa6f2de
193 changed files with 2921 additions and 2567 deletions
|
|
@ -44,7 +44,7 @@ import io.element.android.libraries.matrix.api.exception.ClientException
|
|||
import io.element.android.libraries.matrix.api.exception.ErrorKind
|
||||
import io.element.android.libraries.matrix.api.getRoomInfoFlow
|
||||
import io.element.android.libraries.matrix.api.room.CurrentUserMembership
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoomInfo
|
||||
import io.element.android.libraries.matrix.api.room.RoomInfo
|
||||
import io.element.android.libraries.matrix.api.room.RoomMember
|
||||
import io.element.android.libraries.matrix.api.room.RoomType
|
||||
import io.element.android.libraries.matrix.api.room.isDm
|
||||
|
|
@ -131,7 +131,7 @@ class JoinRoomPresenter @AssistedInject constructor(
|
|||
val result = matrixClient.getRoomPreview(roomIdOrAlias, serverNames)
|
||||
value = result.fold(
|
||||
onSuccess = { preview ->
|
||||
val membershipInfo = when (preview.info.membership) {
|
||||
val membershipInfo = when (preview.previewInfo.membership) {
|
||||
CurrentUserMembership.INVITED,
|
||||
CurrentUserMembership.BANNED,
|
||||
CurrentUserMembership.KNOCKED -> {
|
||||
|
|
@ -139,7 +139,7 @@ class JoinRoomPresenter @AssistedInject constructor(
|
|||
}
|
||||
else -> null
|
||||
}
|
||||
preview.info.toContentState(
|
||||
preview.previewInfo.toContentState(
|
||||
senderMember = membershipInfo?.senderMember,
|
||||
reason = membershipInfo?.currentUserMember?.membershipChangeReason,
|
||||
)
|
||||
|
|
@ -296,7 +296,7 @@ internal fun RoomDescription.toContentState(): ContentState {
|
|||
}
|
||||
|
||||
@VisibleForTesting
|
||||
internal fun MatrixRoomInfo.toContentState(membershipSender: RoomMember?, reason: String?): ContentState {
|
||||
internal fun RoomInfo.toContentState(membershipSender: RoomMember?, reason: String?): ContentState {
|
||||
return ContentState.Loaded(
|
||||
roomId = id,
|
||||
name = name,
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ interface CancelKnockRoom {
|
|||
class DefaultCancelKnockRoom @Inject constructor(private val client: MatrixClient) : CancelKnockRoom {
|
||||
override suspend fun invoke(roomId: RoomId): Result<Unit> {
|
||||
return client
|
||||
.getPendingRoom(roomId)
|
||||
?.leave()
|
||||
.getRoom(roomId)
|
||||
?.use { it.leave() }
|
||||
?: Result.failure(IllegalStateException("No pending room found"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@ interface ForgetRoom {
|
|||
@ContributesBinding(SessionScope::class)
|
||||
class DefaultForgetRoom @Inject constructor(private val client: MatrixClient) : ForgetRoom {
|
||||
override suspend fun invoke(roomId: RoomId): Result<Unit> {
|
||||
return client
|
||||
.getPendingRoom(roomId)
|
||||
?.forget()
|
||||
?: Result.failure(IllegalStateException("No pending room found"))
|
||||
return client.getRoom(roomId)?.use { it.forget() }
|
||||
?: Result.failure(IllegalStateException("Room not found"))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue