From 6b8552fac1384bbbc11174f214e6824e19dca23f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 29 Apr 2024 15:50:56 +0200 Subject: [PATCH] Ensure `editMessage`, `enterSpecialMode` and `replyMessage` are called on the current timeline. --- .../libraries/matrix/api/room/MatrixRoom.kt | 6 ----- .../matrix/impl/room/RustMatrixRoom.kt | 18 ------------- .../matrix/test/room/FakeMatrixRoom.kt | 26 ------------------- 3 files changed, 50 deletions(-) diff --git a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt index fc4ded247a..33cd86c005 100644 --- a/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt +++ b/libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/room/MatrixRoom.kt @@ -131,12 +131,6 @@ interface MatrixRoom : Closeable { suspend fun sendMessage(body: String, htmlBody: String?, mentions: List): Result - suspend fun editMessage(originalEventId: EventId?, transactionId: TransactionId?, body: String, htmlBody: String?, mentions: List): Result - - suspend fun enterSpecialMode(eventId: EventId?): Result - - suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?, mentions: List): Result - suspend fun redactEvent(eventId: EventId, reason: String? = null): Result suspend fun sendImage( diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt index a981a64fd2..1fe5d78627 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt @@ -326,24 +326,6 @@ class RustMatrixRoom( return liveTimeline.sendMessage(body, htmlBody, mentions) } - override suspend fun editMessage( - originalEventId: EventId?, - transactionId: TransactionId?, - body: String, - htmlBody: String?, - mentions: List, - ): Result { - return liveTimeline.editMessage(originalEventId, transactionId, body, htmlBody, mentions) - } - - override suspend fun enterSpecialMode(eventId: EventId?): Result { - return liveTimeline.enterSpecialMode(eventId) - } - - override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?, mentions: List): Result { - return liveTimeline.replyMessage(eventId, body, htmlBody, mentions) - } - override suspend fun redactEvent(eventId: EventId, reason: String?) = withContext(roomDispatcher) { runCatching { innerRoom.redact(eventId.value, reason) diff --git a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt index 7a6920e4dc..a435a7a4ca 100644 --- a/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt +++ b/libraries/matrix/test/src/main/kotlin/io/element/android/libraries/matrix/test/room/FakeMatrixRoom.kt @@ -134,7 +134,6 @@ class FakeMatrixRoom( private var updatePowerLevelsResult = Result.success(Unit) private var resetPowerLevelsResult = Result.success(defaultRoomPowerLevels()) var sendMessageMentions = emptyList() - val editMessageCalls = mutableListOf>() private val _typingRecord = mutableListOf() val typingRecord: List get() = _typingRecord @@ -296,31 +295,6 @@ class FakeMatrixRoom( return eventPermalinkResult(eventId) } - override suspend fun editMessage( - originalEventId: EventId?, - transactionId: TransactionId?, - body: String, - htmlBody: String?, - mentions: List - ): Result { - sendMessageMentions = mentions - editMessageCalls += body to htmlBody - return Result.success(Unit) - } - - var replyMessageParameter: Pair? = null - private set - - override suspend fun enterSpecialMode(eventId: EventId?): Result { - return Result.success(Unit) - } - - override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?, mentions: List): Result { - sendMessageMentions = mentions - replyMessageParameter = body to htmlBody - return Result.success(Unit) - } - var redactEventEventIdParam: EventId? = null private set