mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Use Profiles sliding sync extension check for own profile subscription (#7403)
* Use Profiles sliding sync extension check for own profile subscription --------- Co-authored-by: Jorge Martin Espinosa <jorgem@element.io>
This commit is contained in:
+3
@@ -245,6 +245,9 @@ interface MatrixClient : ClientUrlContentFetcher {
|
|||||||
/** Whether the homeserver advertises support for user status (MSC4426). */
|
/** Whether the homeserver advertises support for user status (MSC4426). */
|
||||||
suspend fun isUserStatusSupported(): Result<Boolean>
|
suspend fun isUserStatusSupported(): Result<Boolean>
|
||||||
|
|
||||||
|
/** Whether the homeserver advertises support for the Profiles sliding sync extension (MSC4262). */
|
||||||
|
suspend fun isProfilesSlidingSyncExtensionSupported(): Result<Boolean>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable automatically setting the user's status to "in a call" (m.call) while in a call.
|
* Enable or disable automatically setting the user's status to "in a call" (m.call) while in a call.
|
||||||
*
|
*
|
||||||
|
|||||||
+9
-1
@@ -326,7 +326,9 @@ class RustMatrixClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun setupUserProfile() {
|
private suspend fun setupUserProfile() {
|
||||||
val supported = isUserStatusSupported().getOrDefault(false)
|
// Subscribing to own profile updates only requires the Profiles sliding sync extension,
|
||||||
|
// not the full user status capability (which also needs the status profile field to be settable).
|
||||||
|
val supported = isProfilesSlidingSyncExtensionSupported().getOrDefault(false)
|
||||||
if (supported) {
|
if (supported) {
|
||||||
// No need to seed the data here, it's already stored by the sdk.
|
// No need to seed the data here, it's already stored by the sdk.
|
||||||
ownProfileTaskHandle = innerClient.subscribeToOwnProfile(ownProfileListener)
|
ownProfileTaskHandle = innerClient.subscribeToOwnProfile(ownProfileListener)
|
||||||
@@ -536,6 +538,12 @@ class RustMatrixClient(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override suspend fun isProfilesSlidingSyncExtensionSupported(): Result<Boolean> = withContext(sessionDispatcher) {
|
||||||
|
runCatchingExceptions {
|
||||||
|
innerClient.isProfilesSlidingSyncExtensionSupported()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun enableAutomaticCallStatus(enabled: Boolean) {
|
override fun enableAutomaticCallStatus(enabled: Boolean) {
|
||||||
innerClient.enableAutomaticCallStatus(enabled)
|
innerClient.enableAutomaticCallStatus(enabled)
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -61,6 +61,7 @@ class FakeFfiClient(
|
|||||||
private val accountDataResult: (String) -> String? = { lambdaError() },
|
private val accountDataResult: (String) -> String? = { lambdaError() },
|
||||||
private val setAccountDataResult: (String, String) -> Unit = { _, _ -> lambdaError() },
|
private val setAccountDataResult: (String, String) -> Unit = { _, _ -> lambdaError() },
|
||||||
private val isUserStatusSupportedResult: () -> Boolean = { false },
|
private val isUserStatusSupportedResult: () -> Boolean = { false },
|
||||||
|
private val isProfilesSlidingSyncExtensionSupportedResult: () -> Boolean = { false },
|
||||||
private val subscribeToOwnProfileResult: (ProfileListener) -> Unit = {},
|
private val subscribeToOwnProfileResult: (ProfileListener) -> Unit = {},
|
||||||
private val getUrlResult: (String) -> ByteArray = { lambdaError() },
|
private val getUrlResult: (String) -> ByteArray = { lambdaError() },
|
||||||
private val closeResult: () -> Unit = {},
|
private val closeResult: () -> Unit = {},
|
||||||
@@ -103,6 +104,8 @@ class FakeFfiClient(
|
|||||||
|
|
||||||
override suspend fun isUserStatusSupported(): Boolean = isUserStatusSupportedResult()
|
override suspend fun isUserStatusSupported(): Boolean = isUserStatusSupportedResult()
|
||||||
|
|
||||||
|
override suspend fun isProfilesSlidingSyncExtensionSupported(): Boolean = isProfilesSlidingSyncExtensionSupportedResult()
|
||||||
|
|
||||||
override fun subscribeToOwnProfile(listener: ProfileListener): TaskHandle {
|
override fun subscribeToOwnProfile(listener: ProfileListener): TaskHandle {
|
||||||
subscribeToOwnProfileResult(listener)
|
subscribeToOwnProfileResult(listener)
|
||||||
return FakeFfiTaskHandle()
|
return FakeFfiTaskHandle()
|
||||||
|
|||||||
+3
@@ -149,6 +149,7 @@ class FakeMatrixClient(
|
|||||||
var setUserStatusResult: Result<Unit> = Result.success(Unit)
|
var setUserStatusResult: Result<Unit> = Result.success(Unit)
|
||||||
var clearUserStatusResult: Result<Unit> = Result.success(Unit)
|
var clearUserStatusResult: Result<Unit> = Result.success(Unit)
|
||||||
var isUserStatusSupportedResult: Result<Boolean> = Result.success(true)
|
var isUserStatusSupportedResult: Result<Boolean> = Result.success(true)
|
||||||
|
var isProfilesSlidingSyncExtensionSupportedResult: Result<Boolean> = Result.success(true)
|
||||||
|
|
||||||
private val _userProfile: MutableStateFlow<MatrixUser> = MutableStateFlow(MatrixUser(sessionId, userDisplayName, userAvatarUrl))
|
private val _userProfile: MutableStateFlow<MatrixUser> = MutableStateFlow(MatrixUser(sessionId, userDisplayName, userAvatarUrl))
|
||||||
override val userProfile: StateFlow<MatrixUser> = _userProfile
|
override val userProfile: StateFlow<MatrixUser> = _userProfile
|
||||||
@@ -295,6 +296,8 @@ class FakeMatrixClient(
|
|||||||
|
|
||||||
override suspend fun isUserStatusSupported(): Result<Boolean> = isUserStatusSupportedResult
|
override suspend fun isUserStatusSupported(): Result<Boolean> = isUserStatusSupportedResult
|
||||||
|
|
||||||
|
override suspend fun isProfilesSlidingSyncExtensionSupported(): Result<Boolean> = isProfilesSlidingSyncExtensionSupportedResult
|
||||||
|
|
||||||
override fun enableAutomaticCallStatus(enabled: Boolean) = enableAutomaticCallStatusLambda(enabled)
|
override fun enableAutomaticCallStatus(enabled: Boolean) = enableAutomaticCallStatusLambda(enabled)
|
||||||
|
|
||||||
override suspend fun joinRoom(roomId: RoomId): Result<RoomInfo?> = joinRoomLambda(roomId)
|
override suspend fun joinRoom(roomId: RoomId): Result<RoomInfo?> = joinRoomLambda(roomId)
|
||||||
|
|||||||
Reference in New Issue
Block a user