From d5780507c90f35df7afa2b8a3720468207dd486a Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 13 Oct 2026 09:26:55 +0200 Subject: [PATCH] Make storeUserProfile main-safe instead of wrapping getUserProfile --- .../libraries/matrix/impl/RustMatrixClient.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt index 44b33e74a7..e81eac569a 100644 --- a/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt +++ b/libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt @@ -519,20 +519,18 @@ class RustMatrixClient( } } - override suspend fun getUserProfile(): Result = withContext(sessionDispatcher) { - getProfile(sessionId) - .onSuccess { matrixUser -> - // Also update our session storage - _userProfile.emit(matrixUser) - storeUserProfile(matrixUser) - } - } + override suspend fun getUserProfile(): Result = getProfile(sessionId) + .onSuccess { matrixUser -> + // Also update our session storage + _userProfile.emit(matrixUser) + storeUserProfile(matrixUser) + } /** * Store the user profile in the session storage, including a base64 encoded thumbnail of the avatar, * so that the avatar can be rendered without having to use this client. */ - private suspend fun storeUserProfile(matrixUser: MatrixUser) { + private suspend fun storeUserProfile(matrixUser: MatrixUser): Unit = withContext(sessionDispatcher) { val avatarUrl = matrixUser.avatarUrl val storedSession = sessionStore.getSession(sessionId.value) val avatarData = when {