File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Sources/StreamChatSwiftUI/ChatChannelList Expand file tree Collapse file tree 2 files changed +19
-1
lines changed 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) "
96
+ " \( cid. id) - \( lastMessageAt ?? createdAt) - \( lastActiveMembersCount) - \( mutedString) - \( unreadCount. messages) - \( typingUsersString ) "
97
97
}
98
98
99
99
public var lastActiveMembersCount : Int {
@@ -102,4 +102,11 @@ extension ChatChannel: Identifiable {
102
102
}
103
103
. count
104
104
}
105
+
106
+ public var typingUsersString : String {
107
+ currentlyTypingUsers. map { user in
108
+ user. id
109
+ }
110
+ . joined ( separator: " - " )
111
+ }
105
112
}
Original file line number Diff line number Diff line change @@ -75,6 +75,8 @@ public struct ChatChannelListItem: View {
75
75
private var subtitleText : String {
76
76
if channel. isMuted {
77
77
return L10n . Channel. Item. muted
78
+ } else if !channel. currentlyTypingUsers. isEmpty {
79
+ return typingIndicatorString ( for: Array ( channel. currentlyTypingUsers) )
78
80
} else if let latestMessage = channel. latestMessages. first {
79
81
return " \( latestMessage. author. name ?? latestMessage. author. id) : \( latestMessage. textContent ?? latestMessage. text) "
80
82
} else {
@@ -96,6 +98,15 @@ public struct ChatChannelListItem: View {
96
98
return " "
97
99
}
98
100
}
101
+
102
+ private func typingIndicatorString( for typingUsers: [ ChatUser ] ) -> String {
103
+ if let user = typingUsers. first ( where: { user in user. name != nil } ) , let name = user. name {
104
+ return L10n . MessageList. TypingIndicator. users ( name, typingUsers. count - 1 )
105
+ } else {
106
+ // If we somehow cannot fetch any user name, we simply show that `Someone is typing`
107
+ return L10n . MessageList. TypingIndicator. typingUnknown
108
+ }
109
+ }
99
110
}
100
111
101
112
/// View for the avatar used in channels (includes online indicator overlay).
You can’t perform that action at this time.
0 commit comments