8000 Fix showing message sent indicator when message failed to send · GetStream/stream-chat-swiftui@8938fbd · GitHub
[go: up one dir, main page]

Skip to content

Commit 8938fbd

Browse files
committed
Fix showing message sent indicator when message failed to send
1 parent 8addc2c commit 8938fbd

File tree

4 files changed

+33
-1
lines changed

4 files changed

+33
-1
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListHelperViews.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ public struct MessageReadIndicatorView: View {
124124
.customizable()
125125
.foregroundColor(!readUsers.isEmpty ? colors.tintColor : Color(colors.textLowEmphasis))
126126
.frame(height: 16)
127+
.opacity(localState == .sendingFailed ? 0.0 : 1)
127128
.accessibilityLabel(
128129
Text(
129130
readUsers.isEmpty ? L10n.Message.ReadStatus.seenByNoOne : L10n.Message.ReadStatus.seenByOthers
@@ -136,7 +137,12 @@ public struct MessageReadIndicatorView: View {
136137
}
137138

138139
private var image: UIImage {
139-
!readUsers.isEmpty ? images.readByAll : (localState == .pendingSend ? images.messageReceiptSending : images.messageSent)
140+
!readUsers.isEmpty ? images.readByAll : (isMessageSending ? images.messageReceiptSending : images.messageSent)
141+
}
142+
143+
private var isMessageSending: Bool {
144+
localState == .sending
145+
|| localState == .pendingSend
140146
}
141147
}
142148

StreamChatSwiftUITests/Tests/ChatChannel/MessageReadIndicatorView_Tests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,30 @@ class MessageReadIndicatorView_Tests: StreamChatTestCase {
5858
// Then
5959
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
6060
}
61+
62+
func test_messageReadIndicatorView_snapshotSending() {
63+
// Given
64+
let view = MessageReadIndicatorView(
65+
readUsers: [],
66+
showReadCount: false,
67+
localState: .sending
68+
)
69+
.frame(width: 50, height: 16)
70+
71+
// Then
72+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
73+
}
74+
75+
func test_messageReadIndicatorView_snapshotMessageFailed() {
76+
// Given
77+
let view = MessageReadIndicatorView(
78+
readUsers: [],
79+
showReadCount: false,
80+
localState: .sendingFailed
81+
)
82+
.frame(width: 50, height: 16)
83+
84+
// Then
85+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
86+
}
6187
}

0 commit comments

Comments
 (0)
0