Skip to content

Commit 96aeb8f

Browse files
Show all members in direct message channel info view (#760)
1 parent b4cf74b commit 96aeb8f

File tree

6 files changed

+31
-7
lines changed

6 files changed

+31
-7
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
### 🐞 Fixed
77
- Fix visibility of tabbar when reactions are shown [#750](https://github.com/GetStream/stream-chat-swiftui/pull/750)
8+
- Show all members in direct message channel info view [#760](https://github.com/GetStream/stream-chat-swiftui/pull/760)
89
### 🔄 Changed
910
- Only show "Pin/Unpin message" Action if user has permission [#749](https://github.com/GetStream/stream-chat-swiftui/pull/749)
1011
- Filter deactivated users in channel info view [#758](https://github.com/GetStream/stream-chat-swiftui/pull/758)

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoHelperViews.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ public struct ChatInfoOptionsView: View {
6464

6565
public var body: some View {
6666
VStack(spacing: 0) {
67-
if !viewModel.channel.isDirectMessageChannel {
68-
ChannelNameUpdateView(viewModel: viewModel)
69-
} else {
67+
if viewModel.showSingleMemberDMView {
7068
ChatInfoMentionText(participant: viewModel.displayedParticipants.first)
69+
} else if !viewModel.channel.isDirectMessageChannel {
70+
ChannelNameUpdateView(viewModel: viewModel)
7171
}
7272

7373
Divider()

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct ChatChannelInfoView: View, KeyboardReadable {
3636
ZStack {
3737
ScrollView {
3838
LazyVStack(spacing: 0) {
39-
if viewModel.channel.isDirectMessageChannel {
39+
if viewModel.showSingleMemberDMView {
4040
ChatInfoDirectChannelView(
4141
participant: viewModel.displayedParticipants.first
4242
)
@@ -125,7 +125,7 @@ public struct ChatChannelInfoView: View, KeyboardReadable {
125125
.toolbar {
126126
ToolbarItem(placement: .principal) {
127127
Group {
128-
if viewModel.channel.isDirectMessageChannel {
128+
if viewModel.showSingleMemberDMView {
129129
Text(viewModel.displayedParticipants.first?.chatUser.name ?? "")
130130
.font(fonts.bodyBold)
131131
.foregroundColor(Color(colors.text))

Sources/StreamChatSwiftUI/ChatChannel/ChannelInfo/ChatChannelInfoViewModel.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,13 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
5959
var channelController: ChatChannelController!
6060
private var memberListController: ChatChannelMemberListController!
6161
private var loadingUsers = false
62+
63+
public var showSingleMemberDMView: Bool {
64+
channel.isDirectMessageChannel && participants.count <= 2
65+
}
6266

6367
public var displayedParticipants: [ParticipantInfo] {
64-
if channel.isDirectMessageChannel,
68+
if showSingleMemberDMView,
6569
let otherParticipant = participants.first(where: { info in
6670
info.id != chatClient.currentUserId
6771
}) {
@@ -110,7 +114,7 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
110114
}
111115

112116
public var showMoreUsersButton: Bool {
113-
!channel.isDirectMessageChannel && memberListCollapsed && notDisplayedParticipantsCount > 0
117+
!showSingleMemberDMView && memberListCollapsed && notDisplayedParticipantsCount > 0
114118
}
115119

116120
public init(channel: ChatChannel) {

StreamChatSwiftUITests/Tests/ChatChannel/ChannelInfo/ChatChannelInfoView_Tests.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ class ChatChannelInfoView_Tests: StreamChatTestCase {
4949
// Then
5050
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
5151
}
52+
53+
func test_chatChannelInfoView_directChannelMoreMembersSnapshot() {
54+
// Given
55+
let members = ChannelInfoMockUtils.setupMockMembers(
56+
count: 4,
57+
currentUserId: chatClient.currentUserId!
58+
)
59+
let channel = ChatChannel.mockDMChannel(
60+
name: "Direct channel",
61+
lastActiveMembers: members
62+
)
63+
64+
// When
65+
let view = ChatChannelInfoView(channel: channel)
66+
.applyDefaultSize()
67+
68+
// Then
69+
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
70+
}
5271

5372
func test_chatChannelInfoView_directChannelMutedSnapshot() {
5473
// Given
Loading

0 commit comments

Comments
 (0)