Fix disambiguated with empty senderName

This commit is contained in:
ganfra 2019-10-30 19:25:24 +01:00
parent 035359cb35
commit 101057520b

View file

@ -62,17 +62,10 @@ data class TimelineEvent(
} }
fun getDisambiguatedDisplayName(): String { fun getDisambiguatedDisplayName(): String {
val disambiguated = if (isUniqueDisplayName) { return when {
senderName senderName.isNullOrBlank() -> root.senderId ?: ""
} else { isUniqueDisplayName -> senderName
senderName?.let { name -> else -> "$senderName (${root.senderId})"
"$name (${root.senderId})"
}
}
return if (disambiguated.isNullOrBlank()) {
root.senderId ?: ""
} else {
disambiguated
} }
} }
@ -107,7 +100,7 @@ fun TimelineEvent.getEditedEventId(): String? {
* Get last MessageContent, after a possible edition * Get last MessageContent, after a possible edition
*/ */
fun TimelineEvent.getLastMessageContent(): MessageContent? = annotations?.editSummary?.aggregatedContent?.toModel() fun TimelineEvent.getLastMessageContent(): MessageContent? = annotations?.editSummary?.aggregatedContent?.toModel()
?: root.getClearContent().toModel() ?: root.getClearContent().toModel()
/** /**
* Get last Message body, after a possible edition * Get last Message body, after a possible edition
@ -117,7 +110,7 @@ fun TimelineEvent.getLastMessageBody(): String? {
if (lastMessageContent != null) { if (lastMessageContent != null) {
return lastMessageContent.newContent?.toModel<MessageContent>()?.body return lastMessageContent.newContent?.toModel<MessageContent>()?.body
?: lastMessageContent.body ?: lastMessageContent.body
} }
return null return null