diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/SendService.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/SendService.kt index de85438b1c..fd596de328 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/SendService.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/room/send/SendService.kt @@ -124,8 +124,14 @@ interface SendService { */ fun deleteFailedEcho(localEcho: TimelineEvent) + /** + * Delete all the events in one of the sending states + */ fun clearSendingQueue() + /** + * Cancel sending a specific event. It has to be in one of the sending states + */ fun cancelSend(eventId: String) /** diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/MatrixDigestCheckInputStream.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/MatrixDigestCheckInputStream.kt index 01de479ff5..9ae4703e05 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/MatrixDigestCheckInputStream.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/attachments/MatrixDigestCheckInputStream.kt @@ -22,9 +22,12 @@ import java.io.IOException import java.io.InputStream import java.security.MessageDigest -class MatrixDigestCheckInputStream(`in`: InputStream?, val expectedDigest: String) : FilterInputStream(`in`) { +class MatrixDigestCheckInputStream( + inputStream: InputStream?, + private val expectedDigest: String +) : FilterInputStream(inputStream) { - val digest = MessageDigest.getInstance("SHA-256") + private val digest = MessageDigest.getInstance("SHA-256") @Throws(IOException::class) override fun read(): Int { diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt index f29ff4c330..ddb21b9f2f 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailViewModel.kt @@ -1076,12 +1076,12 @@ class RoomDetailViewModel @AssistedInject constructor( private fun handleCancel(action: RoomDetailAction.CancelSend) { val targetEventId = action.eventId room.getTimeLineEvent(targetEventId)?.let { - // State must be UNDELIVERED or Failed + // State must be in one of the sending states if (!it.root.sendState.isSending()) { - Timber.e("Cannot resend message, it is not failed, Cancel first") + Timber.e("Cannot cancel message, it is not sending") return } - room.cancelSend(action.eventId) + room.cancelSend(targetEventId) } }