Fix bullet points not having leading margin on timeline items (#4536)

* Fix bullet points not having leading margin on timeline items

* Remove other usages of `SpannableString` constructor, use either `valueOf` to reuse the existing value or `SpannedString` instead if the spans don't have to change
This commit is contained in:
Jorge Martin Espinosa 2025-04-07 10:50:45 +02:00 committed by GitHub
parent b1dd555baa
commit 977268b876
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 8 additions and 10 deletions

View file

@ -16,11 +16,11 @@ import io.element.android.libraries.core.extensions.orEmpty
@Stable
class StableCharSequence(initialText: CharSequence = "") {
private var value by mutableStateOf<SpannableString>(SpannableString(initialText))
private var value by mutableStateOf<SpannableString>(SpannableString.valueOf(initialText))
private var needsDisplaying by mutableStateOf(false)
fun update(newText: CharSequence?, needsDisplaying: Boolean) {
value = SpannableString(newText.orEmpty())
value = SpannableString.valueOf(newText.orEmpty())
this.needsDisplaying = needsDisplaying
}

View file

@ -9,7 +9,6 @@ package io.element.android.libraries.textcomposer.model
import android.os.Parcelable
import android.text.Spannable
import android.text.SpannableString
import android.text.SpannableStringBuilder
import android.text.Spanned
import androidx.compose.runtime.Composable
@ -118,8 +117,7 @@ class MarkdownTextEditorState(
}
fun getMentions(): List<IntentionalMention> {
val text = SpannableString(text.value())
val mentionSpans = text.getMentionSpans()
val mentionSpans = text.value().getMentionSpans()
return mentionSpans.mapNotNull { mentionSpan ->
when (mentionSpan.type) {
is MentionType.User -> IntentionalMention.User(mentionSpan.type.userId)