mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-16 01:55:04 +08:00
Create getBestName method for User
This commit is contained in:
parent
ec0cba2b23
commit
b95dfa4473
@ -24,4 +24,9 @@ data class User(
|
||||
val userId: String,
|
||||
val displayName: String? = null,
|
||||
val avatarUrl: String? = null
|
||||
)
|
||||
) {
|
||||
/**
|
||||
* Return the display name or the user id
|
||||
*/
|
||||
fun getBestName() = displayName?.takeIf { it.isNotEmpty() } ?: userId
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
|
||||
val chip = Chip(requireContext())
|
||||
chip.setChipBackgroundColorResource(android.R.color.transparent)
|
||||
chip.chipStrokeWidth = dimensionConverter.dpToPx(1).toFloat()
|
||||
chip.text = if (user.displayName.isNullOrBlank()) user.userId else user.displayName
|
||||
chip.text = user.getBestName()
|
||||
chip.isClickable = true
|
||||
chip.isCheckable = false
|
||||
chip.isCloseIconVisible = true
|
||||
|
@ -203,7 +203,7 @@ class NotificationDrawerManager @Inject constructor(private val context: Context
|
||||
|
||||
val user = session.getUser(session.myUserId)
|
||||
// myUserDisplayName cannot be empty else NotificationCompat.MessagingStyle() will crash
|
||||
val myUserDisplayName = user?.displayName?.takeIf { it.isNotBlank() } ?: session.myUserId
|
||||
val myUserDisplayName = user?.getBestName() ?: session.myUserId
|
||||
val myUserAvatarUrl = session.contentUrlResolver().resolveThumbnail(user?.avatarUrl, avatarSize, avatarSize, ContentUrlResolver.ThumbnailMethod.SCALE)
|
||||
synchronized(eventList) {
|
||||
Timber.v("%%%%%%%% REFRESH NOTIFICATION DRAWER ")
|
||||
|
Loading…
Reference in New Issue
Block a user