Skip to content

Commit d8b5cf3

Browse files
nuno-vieiraStream-SDK-BotStream Bot
authored
Display double grey checkmark when delivery events are enabled (#1038)
* Display double grey checkmark when delivery events are enabled * Update CHANGELOG.md * Add MessageReadIndicatorView_Tests * Fix tests compilations * Add test coverage to the channelListItem * [CI] Snapshots (#1039) Co-authored-by: Stream Bot <ci@getstream.io> --------- Co-authored-by: Stream SDK Bot <60655709+Stream-SDK-Bot@users.noreply.github.com> Co-authored-by: Stream Bot <ci@getstream.io>
1 parent 1a6564a commit d8b5cf3

File tree

13 files changed

+140
-11
lines changed

13 files changed

+140
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55

66
### ✅ Added
77
- Add message highlighting on jumping to a quoted message [#1032](https://github.com/GetStream/stream-chat-swiftui/pull/1032)
8+
- Display double grey checkmark when delivery events are enabled [#1038](https://github.com/GetStream/stream-chat-swiftui/pull/1038)
89

910
### 🐞 Fixed
1011
- Fix composer deleting newly entered text after deleting draft text [#1030](https://github.com/GetStream/stream-chat-swiftui/pull/1030)

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageListHelperViews.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,18 @@ public struct MessageReadIndicatorView: View {
100100

101101
var readUsers: [ChatUser]
102102
var showReadCount: Bool
103+
var showDelivered: Bool
103104
var localState: LocalMessageState?
104105

105-
public init(readUsers: [ChatUser], showReadCount: Bool, localState: LocalMessageState? = nil) {
106+
public init(
107+
readUsers: [ChatUser],
108+
showReadCount: Bool,
109+
showDelivered: Bool = false,
110+
localState: LocalMessageState? = nil
111+
) {
106112
self.readUsers = readUsers
107113
self.showReadCount = showReadCount
114+
self.showDelivered = showDelivered
108115
self.localState = localState
109116
}
110117

@@ -135,7 +142,7 @@ public struct MessageReadIndicatorView: View {
135142
}
136143

137144
private var image: UIImage {
138-
shouldShowReads ? images.readByAll : (isMessageSending ? images.messageReceiptSending : images.messageSent)
145+
shouldShowReads || showDelivered ? images.readByAll : (isMessageSending ? images.messageReceiptSending : images.messageSent)
139146
}
140147

141148
private var isMessageSending: Bool {

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListItem.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,10 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
8585
MessageReadIndicatorView(
8686
readUsers: channel.readUsers(
8787
currentUserId: chatClient.currentUserId,
88-
message: channel.latestMessages.first
88+
message: channel.previewMessage
8989
),
90-
showReadCount: false
90+
showReadCount: false,
91+
showDelivered: channel.previewMessage?.deliveryStatus(for: channel) == .delivered
9192
)
9293
}
9394
SubtitleText(text: injectedChannelInfo?.timestamp ?? channel.timestampText)
@@ -159,9 +160,8 @@ public struct ChatChannelListItem<Factory: ViewFactory>: View {
159160
}
160161

161162
private var shouldShowReadEvents: Bool {
162-
if let message = channel.latestMessages.first,
163-
message.isSentByCurrentUser,
164-
!message.isDeleted {
163+
if let message = channel.previewMessage,
164+
message.isSentByCurrentUser {
165165
return channel.config.readEventsEnabled
166166
}
167167

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,9 +1027,11 @@ extension ViewFactory {
10271027
message: message
10281028
)
10291029
let showReadCount = channel.memberCount > 2 && !message.isLastActionFailed
1030+
let showDelivered = message.deliveryStatus(for: channel) == .delivered
10301031
return MessageReadIndicatorView(
10311032
readUsers: readUsers,
10321033
showReadCount: showReadCount,
1034+
showDelivered: showDelivered,
10331035
localState: message.localState
10341036
)
10351037
}

StreamChatSwiftUI.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3945,8 +3945,8 @@
39453945
isa = XCRemoteSwiftPackageReference;
39463946
repositoryURL = "https://github.com/GetStream/stream-chat-swift.git";
39473947
requirement = {
3948-
kind = upToNextMajorVersion;
3949-
minimumVersion = 4.91.0;
3948+
branch = release/4.92.0;
3949+
kind = branch;
39503950
};
39513951
};
39523952
E3A1C01A282BAC66002D1E26 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {

StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/ChatChannelInfoViewModel_Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ class ChatChannelInfoViewModel_Tests: StreamChatTestCase {
389389
let mutedUser = ChatUser.mock(id: .unique)
390390
let viewModel = ChatChannelInfoViewModel(channel: channel)
391391
let currentUserController = CurrentChatUserController_Mock(client: chatClient)
392-
let currentUser = CurrentChatUser.mock(id: .unique, mutedUsers: [mutedUser])
392+
let currentUser = CurrentChatUser.mock(currentUserId: .unique, mutedUsers: [mutedUser])
393393
currentUserController.currentUser_mock = currentUser
394394
viewModel.currentUserController = currentUserController
395395

StreamChatSwiftUITests/Tests/ChatChannel/ChatChannelExtensions_Tests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ class ChatChannelExtensions_Tests: StreamChatTestCase {
6060
// Given
6161
let user = ChatUser.mock(id: .unique)
6262
let messages = [ChatMessage.mock(id: .unique, cid: .unique, text: "Test", author: ChatUser.mock(id: .unique))]
63-
let read = ChatChannelRead(lastReadAt: Date(), lastReadMessageId: nil, unreadMessagesCount: 0, user: user)
63+
let read = ChatChannelRead(
64+
lastReadAt: Date(),
65+
lastReadMessageId: nil,
66+
unreadMessagesCount: 0,
67+
user: user,
68+
lastDeliveredAt: nil,
69+
lastDeliveredMessageId: nil
70+
)
6471
let channel = ChatChannel.mockDMChannel(reads: [read], latestMessages: messages)
6572

6673
// When

StreamChatSwiftUITests/Tests/ChatChannel/MessageReadIndicatorView_Tests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,4 +122,30 @@ class MessageReadIndicatorView_Tests: StreamChatTestCase {
122122
// Then
123123
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
124124
}
125+
126+
func test_messageReadIndicatorView_snapshotMessageDelivered() {
127+
// Given
128+
let view = MessageReadIndicatorView(
129+
readUsers: [],
130+
showReadCount: false,
131+
showDelivered: true
132+
)
133+
.frame(width: 50, height: 16)
134+
135+
// Then
136+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
137+
}
138+
139+
func test_messageReadIndicatorView_snapshotMessageDeliveredAndRead() {
140+
// Given
141+
let view = MessageReadIndicatorView(
142+
readUsers: [.mock(id: .unique), .mock(id: .unique)],
143+
showReadCount: true,
144+
showDelivered: true
145+
)
146+
.frame(width: 50, height: 16)
147+
148+
// Then
149+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
150+
}
125151
}
Loading
Loading

0 commit comments

Comments
 (0)