Skip to content

Commit 1088555

Browse files
Made the read indicator view injectable
1 parent 59092eb commit 1088555

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

Sources/StreamChatSwiftUI/ChatChannel/MessageList/MessageContainerView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ struct MessageContainerView<Factory: ViewFactory>: View {
142142
MessageAuthorAndDateView(message: message)
143143
} else if message.isSentByCurrentUser {
144144
HStack(spacing: 4) {
145-
MessageReadIndicatorView(
145+
factory.makeMessageReadIndicatorView(
146146
readUsers: channel.readUsers(
147147
currentUserId: chatClient.currentUserId
148148
),

Sources/StreamChatSwiftUI/ChatChannelList/ChatChannelListItem.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public struct ChatChannelListItem: View {
7171
}
7272

7373
HStack(spacing: 4) {
74-
if let message = channel.latestMessages.first, message.isSentByCurrentUser {
74+
if let message = channel.latestMessages.first,
75+
message.isSentByCurrentUser,
76+
!message.isDeleted {
7577
MessageReadIndicatorView(
7678
readUsers: channel.readUsers(
7779
currentUserId: chatClient.currentUserId

Sources/StreamChatSwiftUI/DefaultViewFactory.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,16 @@ extension ViewFactory {
553553
handleCommand: handleCommand
554554
)
555555
}
556+
557+
public func makeMessageReadIndicatorView(
558+
readUsers: [ChatUser],
559+
showReadCount: Bool
560+
) -> some View {
561+
MessageReadIndicatorView(
562+
readUsers: readUsers,
563+
showReadCount: showReadCount
564+
)
565+
}
556566
}
557567

558568
/// Default class conforming to `ViewFactory`, used throughout the SDK.

Sources/StreamChatSwiftUI/ViewFactory.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,4 +541,15 @@ public protocol ViewFactory: AnyObject {
541541
suggestions: [String: Any],
542542
handleCommand: @escaping ([String: Any]) -> Void
543543
) -> CommandsContainerViewType
544+
545+
associatedtype MessageReadIndicatorViewType: View
546+
/// Creates the message read indicator view.
547+
/// - Parameters:
548+
/// - readUsers: list of users who read the message.
549+
/// - showReadCount: whether read count should be shown.
550+
/// - Returns: view shown in the message read indicator slot.
551+
func makeMessageReadIndicatorView(
552+
readUsers: [ChatUser],
553+
showReadCount: Bool
554+
) -> MessageReadIndicatorViewType
544555
}

0 commit comments

Comments
 (0)