Merge develop into feature/fga/some_room_related_fixes
This commit is contained in:
commit
1d690fdd00
32 changed files with 594 additions and 88 deletions
|
|
@ -18,7 +18,7 @@ plugins {
|
|||
id("io.element.android-library")
|
||||
id("kotlin-parcelize")
|
||||
alias(libs.plugins.anvil)
|
||||
kotlin("plugin.serialization") version "1.8.10"
|
||||
kotlin("plugin.serialization") version "1.8.20"
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,10 @@ interface MatrixRoom : Closeable {
|
|||
suspend fun redactEvent(eventId: EventId, reason: String? = null): Result<Unit>
|
||||
|
||||
suspend fun leave(): Result<Unit>
|
||||
|
||||
suspend fun acceptInvitation(): Result<Unit>
|
||||
|
||||
suspend fun rejectInvitation(): Result<Unit>
|
||||
}
|
||||
|
||||
fun MatrixRoom.getMemberFlow(userId: UserId): Flow<RoomMember?> {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
plugins {
|
||||
id("io.element.android-library")
|
||||
alias(libs.plugins.anvil)
|
||||
kotlin("plugin.serialization") version "1.8.10"
|
||||
kotlin("plugin.serialization") version "1.8.20"
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class RoomSummaryDetailsFactory(private val roomMessageFactory: RoomMessageFacto
|
|||
roomId = RoomId(slidingSyncRoom.roomId()),
|
||||
name = slidingSyncRoom.name() ?: slidingSyncRoom.roomId(),
|
||||
canonicalAlias = room?.canonicalAlias(),
|
||||
isDirect = slidingSyncRoom.isDm() ?: false,
|
||||
isDirect = room?.isDirect() ?: false,
|
||||
avatarURLString = room?.avatarUrl(),
|
||||
unreadNotificationCount = slidingSyncRoom.unreadNotifications().use { it.notificationCount().toInt() },
|
||||
lastMessage = latestRoomMessage,
|
||||
|
|
|
|||
|
|
@ -182,4 +182,17 @@ class RustMatrixRoom(
|
|||
innerRoom.leave()
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun acceptInvitation(): Result<Unit> = withContext(coroutineDispatchers.io) {
|
||||
kotlin.runCatching {
|
||||
innerRoom.acceptInvitation()
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun rejectInvitation(): Result<Unit> = withContext(coroutineDispatchers.io) {
|
||||
kotlin.runCatching {
|
||||
innerRoom.rejectInvitation()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,10 @@ class FakeMatrixClient(
|
|||
private var createDmFailure: Throwable? = null
|
||||
private var findDmResult: MatrixRoom? = FakeMatrixRoom()
|
||||
private var logoutFailure: Throwable? = null
|
||||
private val getRoomResults = mutableMapOf<RoomId, MatrixRoom>()
|
||||
|
||||
override fun getRoom(roomId: RoomId): MatrixRoom? {
|
||||
return FakeMatrixRoom(sessionId = sessionId, roomId = roomId)
|
||||
return getRoomResults[roomId]
|
||||
}
|
||||
|
||||
override fun findDM(userId: UserId): MatrixRoom? {
|
||||
|
|
@ -136,4 +137,8 @@ class FakeMatrixClient(
|
|||
fun givenFindDmResult(result: MatrixRoom?) {
|
||||
findDmResult = result
|
||||
}
|
||||
|
||||
fun givenGetRoomResult(roomId: RoomId, result: MatrixRoom) {
|
||||
getRoomResults[roomId] = result
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import io.element.android.libraries.matrix.api.core.SessionId
|
|||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoomMembersState
|
||||
import io.element.android.libraries.matrix.api.room.RoomMember
|
||||
import io.element.android.libraries.matrix.api.timeline.MatrixTimeline
|
||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||
|
|
@ -50,6 +51,14 @@ class FakeMatrixRoom(
|
|||
private var userDisplayNameResult = Result.success<String?>(null)
|
||||
private var userAvatarUrlResult = Result.success<String?>(null)
|
||||
private var updateMembersResult: Result<Unit> = Result.success(Unit)
|
||||
private var acceptInviteResult = Result.success(Unit)
|
||||
private var rejectInviteResult = Result.success(Unit)
|
||||
|
||||
var isInviteAccepted: Boolean = false
|
||||
private set
|
||||
|
||||
var isInviteRejected: Boolean = false
|
||||
private set
|
||||
|
||||
private var leaveRoomError: Throwable? = null
|
||||
|
||||
|
|
@ -108,6 +117,15 @@ class FakeMatrixRoom(
|
|||
}
|
||||
|
||||
override suspend fun leave(): Result<Unit> = leaveRoomError?.let { Result.failure(it) } ?: Result.success(Unit)
|
||||
override suspend fun acceptInvitation(): Result<Unit> {
|
||||
isInviteAccepted = true
|
||||
return acceptInviteResult
|
||||
}
|
||||
|
||||
override suspend fun rejectInvitation(): Result<Unit> {
|
||||
isInviteRejected = true
|
||||
return rejectInviteResult
|
||||
}
|
||||
|
||||
override fun close() = Unit
|
||||
|
||||
|
|
@ -130,4 +148,13 @@ class FakeMatrixRoom(
|
|||
fun givenUserAvatarUrlResult(avatarUrl: Result<String?>) {
|
||||
userAvatarUrlResult = avatarUrl
|
||||
}
|
||||
|
||||
fun givenAcceptInviteResult(result: Result<Unit>) {
|
||||
acceptInviteResult = result
|
||||
}
|
||||
|
||||
fun givenRejectInviteResult(result: Result<Unit>) {
|
||||
rejectInviteResult = result
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
plugins {
|
||||
id("io.element.android-library")
|
||||
alias(libs.plugins.anvil)
|
||||
kotlin("plugin.serialization") version "1.8.10"
|
||||
kotlin("plugin.serialization") version "1.8.20"
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
plugins {
|
||||
id("io.element.android-library")
|
||||
alias(libs.plugins.anvil)
|
||||
kotlin("plugin.serialization") version "1.8.10"
|
||||
kotlin("plugin.serialization") version "1.8.20"
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue