Skip to content

Commit 461531e

Browse files
Updated handling of URLs in link attachments
1 parent e80c6f0 commit 461531e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/LinkAttachmentView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public struct LinkAttachmentView: View {
8181
VStack(alignment: .leading, spacing: padding) {
8282
if !imageHidden {
8383
ZStack {
84-
LazyImage(source: linkAttachment.previewURL!)
84+
LazyImage(source: linkAttachment.previewURL ?? linkAttachment.originalURL)
8585
.onDisappear(.cancel)
8686
.processors([ImageProcessors.Resize(width: width)])
8787
.priority(.high)
@@ -90,7 +90,7 @@ public struct LinkAttachmentView: View {
9090

9191
if !authorHidden {
9292
BottomLeftView {
93-
Text(linkAttachment.author!)
93+
Text(linkAttachment.author ?? "")
9494
.foregroundColor(colors.tintColor)
9595
.font(fonts.bodyBold)
9696
.standardPadding()

Sources/StreamChatSwiftUI/ChatChannel/MessageList/QuotedMessageView.swift

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,13 @@ public struct QuotedMessageView<Factory: ViewFactory>: View {
108108
cornerRadius: 0
109109
)
110110
} else if !quotedMessage.linkAttachments.isEmpty {
111-
LazyImage(source: quotedMessage.linkAttachments[0].previewURL!)
112-
.onDisappear(.cancel)
113-
.processors([ImageProcessors.Resize(width: attachmentWidth)])
114-
.priority(.high)
111+
LazyImage(
112+
source: quotedMessage.linkAttachments[0].previewURL ?? quotedMessage.linkAttachments[0]
113+
.originalURL
114+
)
115+
.onDisappear(.cancel)
116+
.processors([ImageProcessors.Resize(width: attachmentWidth)])
117+
.priority(.high)
115118
}
116119
}
117120
.frame(width: attachmentWidth, height: attachmentWidth)

0 commit comments

Comments
 (0)