Skip to content

Commit 81b79d0

Browse files
Fixed message text appearing in multiple file attachments from the same message
1 parent d58e17d commit 81b79d0

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1212
- Channel list item swipe gesture collision with native gesture
1313
- Attributes from `MessageActionInfo` are now public
1414
- Crash on older devices when adding multiple images quickly
15+
- Message text appearing in multiple file attachments from the same message
1516

1617
# [4.24.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.24.0)
1718
_November 16, 2022_

Sources/StreamChatSwiftUI/ChatChannel/MessageList/FileAttachmentView.swift

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,29 +40,22 @@ public struct FileAttachmentsContainer<Factory: ViewFactory>: View {
4040
)
4141
}
4242

43-
VStack(spacing: 4) {
44-
ForEach(message.fileAttachments, id: \.self) { attachment in
45-
if message.text.isEmpty {
43+
VStack(spacing: 0) {
44+
VStack(spacing: 4) {
45+
ForEach(message.fileAttachments, id: \.self) { attachment in
4646
FileAttachmentView(
4747
attachment: attachment,
4848
width: width,
4949
isFirst: isFirst
5050
)
51-
} else {
52-
VStack(spacing: 0) {
53-
FileAttachmentView(
54-
attachment: attachment,
55-
width: width,
56-
isFirst: isFirst
57-
)
58-
59-
HStack {
60-
Text(message.adjustedText)
61-
.foregroundColor(textColor(for: message))
62-
.standardPadding()
63-
Spacer()
64-
}
65-
}
51+
}
52+
}
53+
if !message.text.isEmpty {
54+
HStack {
55+
Text(message.adjustedText)
56+
.foregroundColor(textColor(for: message))
57+
.standardPadding()
58+
Spacer()
6659
}
6760
}
6861
}

StreamChatSwiftUITests/Tests/ChatChannel/MessageView_Tests.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,30 @@ class MessageView_Tests: StreamChatTestCase {
215215
assertSnapshot(matching: view, as: .image)
216216
}
217217

218+
func test_messageViewFileText_snapshot() {
219+
// Given
220+
let fileMessage = ChatMessage.mock(
221+
id: .unique,
222+
cid: .unique,
223+
text: "Test message",
224+
author: .mock(id: .unique),
225+
attachments: ChatChannelTestHelpers.fileAttachments
226+
)
227+
228+
// When
229+
let view = MessageView(
230+
factory: DefaultViewFactory.shared,
231+
message: fileMessage,
232+
contentWidth: defaultScreenSize.width,
233+
isFirst: true,
234+
scrolledId: .constant(nil)
235+
)
236+
.applyDefaultSize()
237+
238+
// Then
239+
assertSnapshot(matching: view, as: .image)
240+
}
241+
218242
func test_messageViewJumboEmoji_snapshot() {
219243
// Given
220244
let emojiMessage = ChatMessage.mock(
65.1 KB
Loading

0 commit comments

Comments
 (0)