fix empty guest names for chat viewholders

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2024-11-27 15:04:13 +01:00
parent 41927d2593
commit b5a84b4a3f
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
6 changed files with 20 additions and 28 deletions

View file

@ -157,10 +157,10 @@ class IncomingDeckCardViewHolder(incomingView: View, payload: Any) : MessageHold
} }
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val actorName = message.actorDisplayName
if (!TextUtils.isEmpty(author)) { if (!actorName.isNullOrBlank()) {
binding.messageAuthor.visibility = View.VISIBLE binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = actorName
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
} }

View file

@ -135,10 +135,10 @@ class IncomingLinkPreviewMessageViewHolder(incomingView: View, payload: Any) :
} }
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val actorName = message.actorDisplayName
if (!TextUtils.isEmpty(author)) { if (!actorName.isNullOrBlank()) {
binding.messageAuthor.visibility = View.VISIBLE binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = actorName
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
} }

View file

@ -35,6 +35,7 @@ import com.nextcloud.talk.extensions.loadChangelogBotAvatar
import com.nextcloud.talk.extensions.loadFederatedUserAvatar import com.nextcloud.talk.extensions.loadFederatedUserAvatar
import com.nextcloud.talk.ui.theme.ViewThemeUtils import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.ApiUtils import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.ChatMessageUtils
import com.nextcloud.talk.utils.DateUtils import com.nextcloud.talk.utils.DateUtils
import com.nextcloud.talk.utils.UriUtils import com.nextcloud.talk.utils.UriUtils
import com.nextcloud.talk.utils.message.MessageUtils import com.nextcloud.talk.utils.message.MessageUtils
@ -119,10 +120,10 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
} }
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val actorName = message.actorDisplayName
if (!TextUtils.isEmpty(author)) { if (!actorName.isNullOrBlank()) {
binding.messageAuthor.visibility = View.VISIBLE binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = actorName
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
} }
@ -131,16 +132,7 @@ class IncomingLocationMessageViewHolder(incomingView: View, payload: Any) :
} }
if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) { if (!message.isGrouped && !message.isOneToOneConversation && !message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.VISIBLE ChatMessageUtils().setAvatarOnMessage(binding.messageUserAvatar, message, viewThemeUtils)
if (message.actorType == "guests") {
// do nothing, avatar is set
} else if (message.actorType == "bots" && message.actorId == "changelog") {
binding.messageUserAvatar.loadChangelogBotAvatar()
} else if (message.actorType == "bots") {
binding.messageUserAvatar.loadBotsAvatar()
} else if (message.actorType == "federated_users") {
binding.messageUserAvatar.loadFederatedUserAvatar(message)
}
} else { } else {
if (message.isOneToOneConversation || message.isFormerOneToOneConversation) { if (message.isOneToOneConversation || message.isFormerOneToOneConversation) {
binding.messageUserAvatar.visibility = View.GONE binding.messageUserAvatar.visibility = View.GONE

View file

@ -142,10 +142,10 @@ class IncomingPollMessageViewHolder(incomingView: View, payload: Any) :
} }
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val actorName = message.actorDisplayName
if (!TextUtils.isEmpty(author)) { if (!actorName.isNullOrBlank()) {
binding.messageAuthor.visibility = View.VISIBLE binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = actorName
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
} }

View file

@ -144,10 +144,10 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
} }
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val actorName = message.actorDisplayName
if (!TextUtils.isEmpty(author)) { if (!actorName.isNullOrBlank()) {
binding.messageAuthor.visibility = View.VISIBLE binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = actorName
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
} }

View file

@ -238,10 +238,10 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
} }
private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) { private fun setAvatarAndAuthorOnMessageItem(message: ChatMessage) {
val author: String = message.actorDisplayName!! val actorName = message.actorDisplayName
if (!TextUtils.isEmpty(author)) { if (!actorName.isNullOrBlank()) {
binding.messageAuthor.visibility = View.VISIBLE binding.messageAuthor.visibility = View.VISIBLE
binding.messageAuthor.text = author binding.messageAuthor.text = actorName
binding.messageUserAvatar.setOnClickListener { binding.messageUserAvatar.setOnClickListener {
(payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context) (payload as? MessagePayload)?.profileBottomSheet?.showFor(message, itemView.context)
} }