Move SessionData.toMatrixUser() extension to a common place, then use it across the codebase.

This commit is contained in:
Benoit Marty
2026-10-02 11:44:23 +02:00
parent def8f7f348
commit dc031dd0e6
7 changed files with 33 additions and 44 deletions
+1
View File
@@ -54,6 +54,7 @@ dependencies {
implementation(projects.libraries.androidutils)
implementation(projects.libraries.architecture)
implementation(projects.services.analytics.api)
implementation(projects.libraries.sessionStorage.api)
testCommonDependencies(libs)
testImplementation(projects.libraries.matrix.test)
@@ -0,0 +1,23 @@
/*
* Copyright (c) 2026 Element Creations 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.user
import io.element.android.libraries.matrix.api.core.UserId
import io.element.android.libraries.sessionstorage.api.SessionData
/**
* Create a [MatrixUser] from the profile data stored locally for the session.
* The avatar thumbnail is used as a fallback when the avatar cannot be loaded,
* for instance for a session which is not the current one.
*/
fun SessionData.toMatrixUser() = MatrixUser(
userId = UserId(userId),
displayName = userDisplayName,
avatarUrl = userAvatarUrl,
avatarThumbnail = userAvatarData,
)