From 4ed3dc1b93f6bf07466c7e48dc8d686b9086024c Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Thu, 29 Jun 2023 11:34:37 +0100 Subject: [PATCH] Trim newlines from message previews. (#1208) - Fixes a bug with replies where the message shows on the line after the sender's name. --- .../Services/Room/RoomSummary/RoomEventStringBuilder.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift b/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift index 33ee0b465..4841edcd4 100644 --- a/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift +++ b/ElementX/Sources/Services/Room/RoomSummary/RoomEventStringBuilder.swift @@ -78,12 +78,13 @@ struct RoomEventStringBuilder { } func prefix(_ eventSummary: String, with sender: TimelineItemSender) -> AttributedString { + let attributedEventSummary = AttributedString(eventSummary.trimmingCharacters(in: .whitespacesAndNewlines)) if let senderDisplayName = sender.displayName, let attributedSenderDisplayName = try? AttributedString(markdown: "**\(senderDisplayName)**") { // Don't include the message body in the markdown otherwise it makes tappable links. - return attributedSenderDisplayName + ": " + AttributedString(eventSummary) + return attributedSenderDisplayName + ": " + attributedEventSummary } else { - return AttributedString(eventSummary) + return attributedEventSummary } } }