Consider the returned value of LinkifyCompat.addLinks

This commit is contained in:
Benoit Marty 2023-12-15 15:16:23 +01:00 committed by Benoit Marty
parent 74729fe534
commit d800b225b6

View file

@ -244,9 +244,6 @@ class TimelineItemContentMessageFactory @Inject constructor(
private fun String.withLinks(): CharSequence? {
val spannable = toSpannable()
LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
if (spannable.getSpans<URLSpan>().isEmpty()) {
return null
}
return spannable
val addedLinks = LinkifyCompat.addLinks(spannable, Linkify.WEB_URLS or Linkify.PHONE_NUMBERS)
return spannable.takeIf { addedLinks }
}