Merge branch 'develop' into julioromano/poll_history_entry_point

This commit is contained in:
ganfra 2023-12-14 15:17:13 +01:00
commit 3ceb2599d8
257 changed files with 916 additions and 1161 deletions

View file

@ -18,6 +18,7 @@ package io.element.android.libraries.matrix.api.permalink
import android.net.Uri
import androidx.compose.runtime.Immutable
import io.element.android.libraries.matrix.api.core.RoomId
import kotlinx.collections.immutable.ImmutableList
/**
@ -32,7 +33,15 @@ sealed interface PermalinkData {
val isRoomAlias: Boolean,
val eventId: String?,
val viaParameters: ImmutableList<String>
) : PermalinkData
) : PermalinkData {
fun getRoomId(): RoomId? {
return roomIdOrAlias.takeIf { !isRoomAlias }?.let(::RoomId)
}
fun getRoomAlias(): String? {
return roomIdOrAlias.takeIf { isRoomAlias }
}
}
/*
* &room_name=Team2

View file

@ -16,7 +16,11 @@
package io.element.android.libraries.matrix.api.room
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.core.UserId
sealed interface Mention {
data class User(val userId: String): Mention
data class User(val userId: UserId): Mention
data object AtRoom: Mention
data class Room(val roomId: RoomId?, val roomAlias: String?): Mention
}

View file

@ -49,7 +49,8 @@ data class PollContent(
val maxSelections: ULong,
val answers: ImmutableList<PollAnswer>,
val votes: ImmutableMap<String, ImmutableList<UserId>>,
val endTime: ULong?
val endTime: ULong?,
val isEdited: Boolean,
) : EventContent
data class UnableToDecryptContent(

View file

@ -0,0 +1,49 @@
/*
* Copyright (c) 2023 New Vector Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.element.android.libraries.matrix.api.permalink
import com.google.common.truth.Truth.assertThat
import kotlinx.collections.immutable.persistentListOf
import org.junit.Test
class PermalinkDataTest {
@Test
fun `getRoomId() returns value when isRoomAlias is false`() {
val permalinkData = PermalinkData.RoomLink(
roomIdOrAlias = "!abcdef123456:matrix.org",
isRoomAlias = false,
eventId = null,
viaParameters = persistentListOf(),
)
assertThat(permalinkData.getRoomId()).isNotNull()
assertThat(permalinkData.getRoomAlias()).isNull()
}
@Test
fun `getRoomAlias() returns value when isRoomAlias is true`() {
val permalinkData = PermalinkData.RoomLink(
roomIdOrAlias = "#room:matrix.org",
isRoomAlias = true,
eventId = null,
viaParameters = persistentListOf(),
)
assertThat(permalinkData.getRoomId()).isNull()
assertThat(permalinkData.getRoomAlias()).isNotNull()
}
}

View file

@ -24,11 +24,20 @@ class BackupUploadStateMapper {
return when (rustEnableProgress) {
RustBackupUploadState.Done ->
BackupUploadState.Done
is RustBackupUploadState.Uploading ->
BackupUploadState.Uploading(
backedUpCount = rustEnableProgress.backedUpCount.toInt(),
totalCount = rustEnableProgress.totalCount.toInt(),
)
is RustBackupUploadState.Uploading -> {
val backedUpCount = rustEnableProgress.backedUpCount.toInt()
val totalCount = rustEnableProgress.totalCount.toInt()
if (backedUpCount == totalCount) {
// Consider that the state is Done in this case,
// the SDK will not send a Done state
BackupUploadState.Done
} else {
BackupUploadState.Uploading(
backedUpCount = backedUpCount,
totalCount = totalCount,
)
}
}
RustBackupUploadState.Waiting ->
BackupUploadState.Waiting
RustBackupUploadState.Error ->

View file

@ -21,6 +21,6 @@ import org.matrix.rustcomponents.sdk.Mentions
fun List<Mention>.map(): Mentions {
val hasAtRoom = any { it is Mention.AtRoom }
val userIds = filterIsInstance<Mention.User>().map { it.userId }
val userIds = filterIsInstance<Mention.User>().map { it.userId.value }
return Mentions(userIds, hasAtRoom)
}

View file

@ -113,6 +113,7 @@ class TimelineEventContentMapper(private val eventMessageMapper: EventMessageMap
vote.value.map { userId -> UserId(userId) }.toImmutableList()
}.toImmutableMap(),
endTime = kind.endTime,
isEdited = kind.hasBeenEdited,
)
}
is TimelineItemContentKind.UnableToDecrypt -> {