mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 15:45:11 +00:00
Fix for the content not updating after an edit, restore the usage of the content based identifier in the formatted body for components.
This commit is contained in:
@@ -68,13 +68,16 @@ struct FormattedBodyText: View {
|
||||
// timestamp would land on top of it, so append an empty trailing plain-text
|
||||
// component that exists solely to reserve space for the timestamp underneath.
|
||||
if trailingReservedSize != .zero, let last = components.last, last.type != .plainText {
|
||||
components.append(AttributedStringBuilderComponent(attributedString: AttributedString(),
|
||||
components.append(AttributedStringBuilderComponent(id: "",
|
||||
attributedString: AttributedString(),
|
||||
type: .plainText))
|
||||
}
|
||||
let lastPlainTextIndex = components.lastIndex { $0.type == .plainText }
|
||||
|
||||
return TimelineBubbleLayout(spacing: 8) {
|
||||
ForEach(Array(components.enumerated()), id: \.offset) { index, component in
|
||||
// The `ForEach` needs to iterate over the id of the element to allow
|
||||
// SwiftUI animations to work properly ater any edit.
|
||||
ForEach(Array(components.enumerated()), id: \.element.id) { index, component in
|
||||
switch component.type {
|
||||
case .blockquote:
|
||||
BlockquoteView(attributedString: component.attributedString, mode: .rendering)
|
||||
@@ -98,7 +101,7 @@ struct FormattedBodyText: View {
|
||||
|
||||
// Make a second iteration through the components adding naturally sized versions of the
|
||||
// block quotes and code blocks which are used for layout calculations but won't be rendered.
|
||||
ForEach(Array(components.enumerated()), id: \.offset) { _, component in
|
||||
ForEach(components) { component in
|
||||
switch component.type {
|
||||
case .blockquote:
|
||||
BlockquoteView(attributedString: component.attributedString, mode: .layout)
|
||||
|
||||
Reference in New Issue
Block a user