Merge branch 'develop' into julioromano/poll_history_entry_point

This commit is contained in:
ganfra 2023-12-14 15:17:13 +01:00
commit 5ac3f273ea
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()
}
}