From 3e4b07cec3cd20486fcd2257afaa0b369b8819cc Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Sat, 14 Dec 2019 10:19:11 +0100 Subject: [PATCH] Do not display " (IRC)") in display names --- CHANGES.md | 1 + .../java/im/vector/matrix/android/api/util/MatrixItem.kt | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a5953dcb14..e6850ef8c7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ Other changes: Bugfix 🐛: - Scroll breadcrumbs to top when opened - Render default room name when it starts with an emoji (#477) + - Do not display " (IRC)") in display names https://github.com/vector-im/riot-android/issues/444 Translations 🗣: - diff --git a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt index c6d5665d0d..aacb5472d9 100644 --- a/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt +++ b/matrix-sdk-android/src/main/java/im/vector/matrix/android/api/util/MatrixItem.kt @@ -29,8 +29,8 @@ sealed class MatrixItem( ) { data class UserItem(override val id: String, override val displayName: String? = null, - override val avatarUrl: String? = null - ) : MatrixItem(id, displayName, avatarUrl) + override val avatarUrl: String? = null) + : MatrixItem(id, displayName?.removeSuffix(ircPattern), avatarUrl) data class EventItem(override val id: String, override val displayName: String? = null, @@ -59,7 +59,7 @@ sealed class MatrixItem( /** * Return the prefix as defined in the matrix spec (and not extracted from the id) */ - fun getPrefix() = when (this) { + fun getIdPrefix() = when (this) { is UserItem -> '@' is EventItem -> '$' is RoomItem -> '!' @@ -103,6 +103,8 @@ sealed class MatrixItem( companion object { + private const val ircPattern = " (IRC)" + fun from(user: User) = UserItem(user.userId, user.displayName, user.avatarUrl) fun from(groupSummary: GroupSummary) = GroupItem(groupSummary.groupId, groupSummary.displayName, groupSummary.avatarUrl) fun from(roomSummary: RoomSummary) = RoomItem(roomSummary.roomId, roomSummary.displayName, roomSummary.avatarUrl)