Merge branch 'develop' into feature/fga/room_list_api

This commit is contained in:
ganfra 2023-06-28 15:14:06 +02:00
commit 8e5c2a749a
935 changed files with 6059 additions and 3293 deletions

View file

@ -26,7 +26,6 @@ import io.element.android.libraries.matrix.api.media.FileInfo
import io.element.android.libraries.matrix.api.media.ImageInfo
import io.element.android.libraries.matrix.api.media.VideoInfo
import io.element.android.libraries.matrix.api.timeline.MatrixTimeline
import io.element.android.libraries.matrix.api.timeline.item.event.MessageContent
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import java.io.Closeable
@ -85,7 +84,7 @@ interface MatrixRoom : Closeable {
suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<Unit>
suspend fun sendReaction(emoji: String, eventId: EventId): Result<Unit>
suspend fun toggleReaction(emoji: String, eventId: EventId): Result<Unit>
suspend fun forwardEvent(eventId: EventId, rooms: List<RoomId>): Result<Unit>

View file

@ -16,7 +16,10 @@
package io.element.android.libraries.matrix.api.timeline.item.event
import io.element.android.libraries.matrix.api.core.UserId
data class EventReaction(
val key: String,
val count: Long
val count: Long,
val senderIds: List<UserId>
)

View file

@ -63,7 +63,8 @@ class RustMatrixAuthenticationService @Inject constructor(
passphrase = null,
// TODO Oidc
// oidcClientMetadata = oidcClientMetadata,
customSlidingSyncProxy = null
customSlidingSyncProxy = null,
userAgent = null, // TODO
)
private var currentHomeserver = MutableStateFlow<MatrixHomeServerDetails?>(null)

View file

@ -303,9 +303,9 @@ class RustMatrixRoom(
}
}
override suspend fun sendReaction(emoji: String, eventId: EventId): Result<Unit> = withContext(coroutineDispatchers.io) {
override suspend fun toggleReaction(emoji: String, eventId: EventId): Result<Unit> = withContext(coroutineDispatchers.io) {
runCatching {
innerRoom.sendReaction(key = emoji, eventId = eventId.value)
innerRoom.toggleReaction(key = emoji, eventId = eventId.value)
}
}

View file

@ -78,7 +78,8 @@ private fun List<Reaction>?.map(): List<EventReaction> {
return this?.map {
EventReaction(
key = it.key,
count = it.count.toLong()
count = it.count.toLong(),
senderIds = it.senders.map { sender -> UserId(sender) }
)
} ?: emptyList()
}

View file

@ -72,7 +72,7 @@ class FakeMatrixRoom(
private var setTopicResult = Result.success(Unit)
private var updateAvatarResult = Result.success(Unit)
private var removeAvatarResult = Result.success(Unit)
private var sendReactionResult = Result.success(Unit)
private var toggleReactionResult = Result.success(Unit)
private var retrySendMessageResult = Result.success(Unit)
private var cancelSendResult = Result.success(Unit)
private var forwardEventResult = Result.success(Unit)
@ -82,8 +82,8 @@ class FakeMatrixRoom(
var sendMediaCount = 0
private set
var sendReactionCount = 0
private set
private val _myReactions = mutableSetOf<String>()
val myReactions: Set<String> = _myReactions
var retrySendMessageCount: Int = 0
private set
@ -150,9 +150,19 @@ class FakeMatrixRoom(
Result.success(Unit)
}
override suspend fun sendReaction(emoji: String, eventId: EventId): Result<Unit> {
sendReactionCount++
return sendReactionResult
override suspend fun toggleReaction(emoji: String, eventId: EventId): Result<Unit> {
if (toggleReactionResult.isFailure) {
// Don't do the toggle if we failed
return toggleReactionResult
}
if(_myReactions.contains(emoji)) {
_myReactions.remove(emoji)
} else {
_myReactions.add(emoji)
}
return toggleReactionResult
}
override suspend fun retrySendMessage(transactionId: String): Result<Unit> {
@ -352,8 +362,8 @@ class FakeMatrixRoom(
setTopicResult = result
}
fun givenSendReactionResult(result: Result<Unit>) {
sendReactionResult = result
fun givenToggleReactionResult(result: Result<Unit>) {
toggleReactionResult = result
}
fun givenRetrySendMessageResult(result: Result<Unit>) {