Skip to content

Commit c6bb054

Browse files
committed
Add a log when User is not kwown.
1 parent 8b1bd79 commit c6bb054

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

matrix-sdk-android/src/main/java/org/matrix/android/sdk/api/session/SessionExtensions.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.matrix.android.sdk.api.session
1919
import org.matrix.android.sdk.api.session.room.Room
2020
import org.matrix.android.sdk.api.session.room.model.RoomSummary
2121
import org.matrix.android.sdk.api.session.user.model.User
22+
import timber.log.Timber
2223

2324
/**
2425
* Get a room using the RoomService of a Session.
@@ -41,4 +42,5 @@ fun Session.getUser(userId: String): User? = userService().getUser(userId)
4142
/**
4243
* Similar to [getUser], but fallback to a User without details if the User is not known by the SDK, or if Session is null.
4344
*/
44-
fun Session?.getUserOrDefault(userId: String): User = this?.userService()?.getUser(userId) ?: User(userId)
45+
fun Session?.getUserOrDefault(userId: String): User = this?.userService()?.getUser(userId)
46+
?: User(userId).also { Timber.w("User $userId not found in local cache, fallback to default") }

0 commit comments

Comments
 (0)