mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Move SessionData.toMatrixUser() extension to a common place, then use it across the codebase.
This commit is contained in:
@@ -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)
|
||||
|
||||
+23
@@ -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,
|
||||
)
|
||||
Reference in New Issue
Block a user