@@ -74,31 +74,30 @@ fun TimelineItemTextView(
7474internal fun getTextWithResolvedMentions (content : TimelineItemTextBasedContent ): CharSequence {
7575 val userProfileCache = LocalRoomMemberProfilesCache .current
7676 val lastCacheUpdate by userProfileCache.lastCacheUpdate.collectAsState()
77- val formattedBody = remember(content.htmlBody, lastCacheUpdate) {
78- updateMentionSpans(content.formattedBody, userProfileCache)
79- SpannableString (content.formattedBody ? : content.body)
77+ val formattedBody = remember(content.formattedBody, lastCacheUpdate) {
78+ content.formattedBody?.let { formattedBody ->
79+ updateMentionSpans(formattedBody, userProfileCache)
80+ formattedBody
81+ }
8082 }
81-
82- return formattedBody
83+ return SpannableString (formattedBody ? : content.body)
8384}
8485
85- private fun updateMentionSpans (text : CharSequence? , cache : RoomMemberProfilesCache ): Boolean {
86+ private fun updateMentionSpans (text : CharSequence , cache : RoomMemberProfilesCache ): Boolean {
8687 var changedContents = false
87- if (text != null ) {
88- for (mentionSpan in text.getMentionSpans()) {
89- when (mentionSpan.type) {
90- MentionSpan .Type .USER -> {
91- val displayName = cache.getDisplayName(UserId (mentionSpan.rawValue)) ? : mentionSpan.rawValue
92- if (mentionSpan.text != displayName) {
93- changedContents = true
94- mentionSpan.text = displayName
95- }
88+ for (mentionSpan in text.getMentionSpans()) {
89+ when (mentionSpan.type) {
90+ MentionSpan .Type .USER -> {
91+ val displayName = cache.getDisplayName(UserId (mentionSpan.rawValue)) ? : mentionSpan.rawValue
92+ if (mentionSpan.text != displayName) {
93+ changedContents = true
94+ mentionSpan.text = displayName
9695 }
97- // There's no need to do anything for `@room` pills
98- MentionSpan .Type .EVERYONE -> Unit
99- // Nothing yet for room mentions
100- MentionSpan .Type .ROOM -> Unit
10196 }
97+ // There's no need to do anything for `@room` pills
98+ MentionSpan .Type .EVERYONE -> Unit
99+ // Nothing yet for room mentions
100+ MentionSpan .Type .ROOM -> Unit
102101 }
103102 }
104103 return changedContents
0 commit comments