diff --git a/CHANGELOG.md b/CHANGELOG.md index 56288a484..52dcb7c21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix visibility of tabbar when reactions are shown [#750](https://github.com/GetStream/stream-chat-swiftui/pull/750) ### 🔄 Changed - Only show "Pin/Unpin message" Action if user has permission [#749](https://github.com/GetStream/stream-chat-swiftui/pull/749) +- Filter deactivated users in channel info view [#758](https://github.com/GetStream/stream-chat-swiftui/pull/758) # [4.72.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.72.0) _February 04, 2025_ diff --git a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift index 7769de40b..ad7041bb5 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift @@ -67,6 +67,8 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe }) { return [otherParticipant] } + + let participants = self.participants.filter { $0.isDeactivated == false } if participants.count <= 6 { return participants @@ -98,7 +100,8 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe public var notDisplayedParticipantsCount: Int { let total = channel.memberCount let displayed = displayedParticipants.count - return total - displayed + let deactivated = participants.filter { $0.isDeactivated }.count + return total - displayed - deactivated } public var mutedText: String { @@ -124,7 +127,8 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe ParticipantInfo( chatUser: member, displayName: member.name ?? member.id, - onlineInfoText: onlineInfo(for: member) + onlineInfoText: onlineInfo(for: member), + isDeactivated: member.isDeactivated ) } } @@ -198,7 +202,8 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe ParticipantInfo( chatUser: member, displayName: member.name ?? member.id, - onlineInfoText: onlineInfo(for: member) + onlineInfoText: onlineInfo(for: member), + isDeactivated: member.isDeactivated ) } } @@ -247,7 +252,8 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe ParticipantInfo( chatUser: member, displayName: member.name ?? member.id, - onlineInfoText: self.onlineInfo(for: member) + onlineInfoText: self.onlineInfo(for: member), + isDeactivated: member.isDeactivated ) } if newMembers.count > self.participants.count { diff --git a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift index 27f046445..c5bf6ed67 100644 --- a/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift +++ b/Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatInfoParticipantsView.swift @@ -48,10 +48,17 @@ public struct ParticipantInfo: Identifiable { public let chatUser: ChatUser public let displayName: String public let onlineInfoText: String + public let isDeactivated: Bool - public init(chatUser: ChatUser, displayName: String, onlineInfoText: String) { + public init( + chatUser: ChatUser, + displayName: String, + onlineInfoText: String, + isDeactivated: Bool = false + ) { self.chatUser = chatUser self.displayName = displayName self.onlineInfoText = onlineInfoText + self.isDeactivated = isDeactivated } } diff --git a/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/ChannelInfoMockUtils.swift b/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/ChannelInfoMockUtils.swift index 4b4953c7c..761019d64 100644 --- a/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/ChannelInfoMockUtils.swift +++ b/StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/ChannelInfoMockUtils.swift @@ -10,7 +10,8 @@ struct ChannelInfoMockUtils { static func setupMockMembers( count: Int, currentUserId: String, - onlineUserIndexes: [Int] = [] + onlineUserIndexes: [Int] = [], + deactivatedUserIndexes: [Int] = [] ) -> [ChatChannelMember] { var activeMembers = [ChatChannelMember]() for i in 0..