File tree Expand file tree Collapse file tree 5 files changed +30
-15
lines changed
Sources/StreamChatSwiftUI Expand file tree Collapse file tree 5 files changed +30
-15
lines changed Original file line number Diff line number Diff line change @@ -143,8 +143,10 @@ struct MessageContainerView<Factory: ViewFactory>: View {
143
143
} else if message. isSentByCurrentUser {
144
144
HStack ( spacing: 4 ) {
145
145
MessageReadIndicatorView (
146
- readUsers: readUsers,
147
- isGroup: isInGroup
146
+ readUsers: channel. readUsers (
147
+ currentUserId: chatClient. currentUserId
148
+ ) ,
149
+ showReadCount: isInGroup
148
150
)
149
151
MessageDateView ( message: message)
150
152
}
@@ -162,14 +164,6 @@ struct MessageContainerView<Factory: ViewFactory>: View {
162
164
. padding ( . top, reactionsShown ? 24 : 0 )
163
165
}
164
166
165
- private var readUsers : [ ChatUser ] {
166
- let readUsers = channel. reads. filter {
167
- $0. lastReadAt > message. createdAt &&
168
- $0. user. id != chatClient. currentUserId
169
- } . map ( \. user)
170
- return readUsers
171
- }
172
-
173
167
private var contentWidth : CGFloat {
174
168
let padding : CGFloat = 8
175
169
let minimumWidth : CGFloat = 240
Original file line number Diff line number Diff line change @@ -46,11 +46,11 @@ struct MessageReadIndicatorView: View {
46
46
@Injected ( \. colors) private var colors
47
47
48
48
var readUsers : [ ChatUser ]
49
- var isGroup : Bool
49
+ var showReadCount : Bool
50
50
51
51
var body : some View {
52
52
HStack ( spacing: 2 ) {
53
- if isGroup && !readUsers. isEmpty {
53
+ if showReadCount && !readUsers. isEmpty {
54
54
Text ( " \( readUsers. count) " )
55
55
. font ( fonts. footnoteBold)
56
56
. foregroundColor ( colors. tintColor)
@@ -59,7 +59,7 @@ struct MessageReadIndicatorView: View {
59
59
uiImage: !readUsers. isEmpty ? images. readByAll : images. messageSent
60
60
)
61
61
. customizable ( )
62
- . foregroundColor ( !readUsers. isEmpty ? colors. tintColor : nil )
62
+ . foregroundColor ( !readUsers. isEmpty ? colors. tintColor : Color ( colors . textLowEmphasis ) )
63
63
. frame ( height: 16 )
64
64
}
65
65
}
Original file line number Diff line number Diff line change @@ -44,6 +44,17 @@ extension ChatChannel {
44
44
}
45
45
}
46
46
47
+ func readUsers( currentUserId: UserId ? ) -> [ ChatUser ] {
48
+ guard let message = latestMessages. first else {
49
+ return [ ]
50
+ }
51
+ let readUsers = reads. filter {
52
+ $0. lastReadAt > message. createdAt &&
53
+ $0. user. id != currentUserId
54
+ } . map ( \. user)
55
+ return readUsers
56
+ }
57
+
47
58
private var lastSeenDateFormatter : ( Date ) -> String ? {
48
59
DateUtils . timeAgo
49
60
}
Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ extension ChatChannel: Identifiable {
93
93
}
94
94
95
95
public var id : String {
96
- " \( cid. id) - \( lastMessageAt ?? createdAt) - \( lastActiveMembersCount) - \( mutedString) - \( unreadCount. messages) - \( typingUsersString) "
96
+ " \( cid. id) - \( lastMessageAt ?? createdAt) - \( lastActiveMembersCount) - \( mutedString) - \( unreadCount. messages) - \( typingUsersString) - \( readUsers ( currentUserId : nil ) . count ) "
97
97
}
98
98
99
99
private var lastActiveMembersCount : Int {
Original file line number Diff line number Diff line change @@ -70,7 +70,17 @@ public struct ChatChannelListItem: View {
70
70
)
71
71
}
72
72
73
- SubtitleText ( text: timestampText)
73
+ HStack ( spacing: 4 ) {
74
+ if let message = channel. latestMessages. first, message. isSentByCurrentUser {
75
+ MessageReadIndicatorView (
76
+ readUsers: channel. readUsers (
77
+ currentUserId: chatClient. currentUserId
78
+ ) ,
79
+ showReadCount: false
80
+ )
81
+ }
82
+ SubtitleText ( text: timestampText)
83
+ }
74
84
}
75
85
}
76
86
. padding ( . all, 8 )
You can’t perform that action at this time.
0 commit comments