Update SDK version to 25.03.13 and fix breaking changes (#4406)

Breaking changes addressed:
* Make `MatrixClient.getNotificationSettings()` async, cache its result.
* Use `RoomInfo` for accessing the updated room's info.
* Refactor `MatrixRoom` so it always receives an initial `MatrixRoomInfo` value: this value will be used to make `MatrixRoom.roomInfoFlow` a `StateFlow` so we can assume the initial updated Room data will be present.
* Fetch encryption state when loading a room if it's unknown
This commit is contained in:
Jorge Martin Espinosa 2025-03-19 12:52:57 +01:00 committed by GitHub
parent 0c07a8165f
commit fccd881b1f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
76 changed files with 647 additions and 431 deletions

View file

@ -18,8 +18,8 @@ fun MatrixRoom.toAnalyticsViewRoom(
val activeSpace = selectedSpace?.toActiveSpace() ?: ViewRoom.ActiveSpace.Home
return ViewRoom(
isDM = isDirect,
isSpace = isSpace,
isDM = info().isDirect,
isSpace = info().isSpace,
trigger = trigger,
activeSpace = activeSpace,
viaKeyboard = viaKeyboard
@ -27,5 +27,5 @@ fun MatrixRoom.toAnalyticsViewRoom(
}
private fun MatrixRoom.toActiveSpace(): ViewRoom.ActiveSpace {
return if (isPublic) ViewRoom.ActiveSpace.Public else ViewRoom.ActiveSpace.Private
return if (info().isPublic) ViewRoom.ActiveSpace.Public else ViewRoom.ActiveSpace.Private
}

View file

@ -8,34 +8,12 @@
package io.element.android.libraries.matrix.api.auth
sealed interface OidcPrompt {
/**
* The Authorization Server must not display any authentication or consent
* user interface pages.
*/
data object None : OidcPrompt
/**
* The Authorization Server should prompt the End-User for
* reauthentication.
*/
data object Login : OidcPrompt
/**
* The Authorization Server should prompt the End-User for consent before
* returning information to the Client.
*/
data object Consent : OidcPrompt
/**
* The Authorization Server should prompt the End-User to select a user
* account.
*
* This enables an End-User who has multiple accounts at the Authorization
* Server to select amongst the multiple accounts that they might have
* current sessions for.
*/
data object SelectAccount : OidcPrompt
/**
* The Authorization Server should prompt the End-User to create a user
* account.

View file

@ -0,0 +1,21 @@
/*
* Copyright 2025 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
* Please see LICENSE files in the repository root for full details.
*/
package io.element.android.libraries.matrix.api.platform
import io.element.android.libraries.matrix.api.tracing.TracingConfiguration
/**
* This service is responsible for initializing the platform-related settings of the SDK.
*/
interface InitPlatformService {
/**
* Initialize the platform-related settings of the SDK.
* @param tracingConfiguration the tracing configuration to use for logging.
*/
fun init(tracingConfiguration: TracingConfiguration)
}

View file

@ -45,21 +45,10 @@ import java.io.File
interface MatrixRoom : Closeable {
val sessionId: SessionId
val roomId: RoomId
val displayName: String
val canonicalAlias: RoomAlias?
val alternativeAliases: List<RoomAlias>
val topic: String?
val avatarUrl: String?
val isEncrypted: Boolean
val isSpace: Boolean
val isDirect: Boolean
val isPublic: Boolean
val activeMemberCount: Long
val joinedMemberCount: Long
val roomCoroutineScope: CoroutineScope
val roomInfoFlow: Flow<MatrixRoomInfo>
val roomInfoFlow: StateFlow<MatrixRoomInfo>
val roomTypingMembersFlow: Flow<List<UserId>>
val identityStateChangesFlow: Flow<List<IdentityStateChange>>
@ -72,7 +61,7 @@ interface MatrixRoom : Closeable {
* A one-to-one is a room with exactly 2 members.
* See [the Matrix spec](https://spec.matrix.org/latest/client-server-api/#default-underride-rules).
*/
val isOneToOne: Boolean get() = activeMemberCount == 2L
val isOneToOne: Boolean get() = info().activeMembersCount == 2L
/**
* The current loaded members as a StateFlow.
@ -83,6 +72,11 @@ interface MatrixRoom : Closeable {
val roomNotificationSettingsStateFlow: StateFlow<MatrixRoomNotificationSettingsState>
/**
* Get the latest room info we have received from the SDK stream.
*/
fun info(): MatrixRoomInfo = roomInfoFlow.value
/**
* Try to load the room members and update the membersFlow.
*/
@ -453,4 +447,6 @@ interface MatrixRoom : Closeable {
* Update the join rule for this room.
*/
suspend fun updateJoinRule(joinRule: JoinRule): Result<Unit>
suspend fun getUpdatedIsEncrypted(): Result<Boolean>
}

View file

@ -27,7 +27,9 @@ data class MatrixRoomInfo(
val rawName: String?,
val topic: String?,
val avatarUrl: String?,
val isPublic: Boolean,
val isDirect: Boolean,
val isEncrypted: Boolean?,
val joinRule: JoinRule?,
val isSpace: Boolean,
val isTombstoned: Boolean,

View file

@ -7,6 +7,8 @@
package io.element.android.libraries.matrix.api.room
import kotlinx.coroutines.flow.first
/**
* Returns whether the room with the provided info is a DM.
* A DM is a room with at most 2 active members (one of them may have left).
@ -19,9 +21,9 @@ fun isDm(isDirect: Boolean, activeMembersCount: Int): Boolean {
}
/**
* Returns whether the [MatrixRoom] is a DM.
* Returns whether the [MatrixRoom] is a DM, with an updated state from the latest [MatrixRoomInfo].
*/
val MatrixRoom.isDm get() = isDm(isDirect, activeMemberCount.toInt())
suspend fun MatrixRoom.isDm() = roomInfoFlow.first().isDm
/**
* Returns whether the [MatrixRoomInfo] is from a DM.

View file

@ -19,7 +19,7 @@ fun MatrixRoom.matches(roomIdOrAlias: RoomIdOrAlias): Boolean {
roomIdOrAlias.roomId == roomId
}
is RoomIdOrAlias.Alias -> {
roomIdOrAlias.roomAlias == canonicalAlias || roomIdOrAlias.roomAlias in alternativeAliases
roomIdOrAlias.roomAlias == info().canonicalAlias || roomIdOrAlias.roomAlias in info().alternativeAliases
}
}
}

View file

@ -32,7 +32,7 @@ suspend fun MatrixClient.getRecentDirectRooms(
getRecentlyVisitedRooms().getOrNull()?.let { roomIds ->
roomIds
.mapNotNull { roomId -> getRoom(roomId) }
.filter { it.isDm && it.isJoined() }
.filter { it.isDm() && it.isJoined() }
.map { room ->
val otherUser = room.getMembers().getOrNull()
?.firstOrNull { it.userId != sessionId }

View file

@ -10,5 +10,6 @@ package io.element.android.libraries.matrix.api.timeline.item.event
enum class TimelineItemEventOrigin {
LOCAL,
SYNC,
PAGINATION
PAGINATION,
CACHE,
}

View file

@ -10,6 +10,5 @@ package io.element.android.libraries.matrix.api.tracing
import timber.log.Timber
interface TracingService {
fun setupTracing(tracingConfiguration: TracingConfiguration)
fun createTimberTree(target: String): Timber.Tree
}