Skip to content

Show all members in direct message channel info view #760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### 🐞 Fixed
- Fix visibility of tabbar when reactions are shown [#750](https://github.com/GetStream/stream-chat-swiftui/pull/750)
- Show all members in direct message channel info view [#760](https://github.com/GetStream/stream-chat-swiftui/pull/760)
### 🔄 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public struct ChatInfoOptionsView: View {

public var body: some View {
VStack(spacing: 0) {
if !viewModel.channel.isDirectMessageChannel {
ChannelNameUpdateView(viewModel: viewModel)
} else {
if viewModel.showSingleMemberDMView {
ChatInfoMentionText(participant: viewModel.displayedParticipants.first)
} else if !viewModel.channel.isDirectMessageChannel {
ChannelNameUpdateView(viewModel: viewModel)
}

Divider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct ChatChannelInfoView: View, KeyboardReadable {
ZStack {
ScrollView {
LazyVStack(spacing: 0) {
if viewModel.channel.isDirectMessageChannel {
if viewModel.showSingleMemberDMView {
ChatInfoDirectChannelView(
participant: viewModel.displayedParticipants.first
)
Expand Down Expand Up @@ -125,7 +125,7 @@ public struct ChatChannelInfoView: View, KeyboardReadable {
.toolbar {
ToolbarItem(placement: .principal) {
Group {
if viewModel.channel.isDirectMessageChannel {
if viewModel.showSingleMemberDMView {
Text(viewModel.displayedParticipants.first?.chatUser.name ?? "")
.font(fonts.bodyBold)
.foregroundColor(Color(colors.text))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
var channelController: ChatChannelController!
private var memberListController: ChatChannelMemberListController!
private var loadingUsers = false

public var showSingleMemberDMView: Bool {
channel.isDirectMessageChannel && participants.count <= 2
}

public var displayedParticipants: [ParticipantInfo] {
if channel.isDirectMessageChannel,
if showSingleMemberDMView,
let otherParticipant = participants.first(where: { info in
info.id != chatClient.currentUserId
}) {
Expand Down Expand Up @@ -110,7 +114,7 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
}

public var showMoreUsersButton: Bool {
!channel.isDirectMessageChannel && memberListCollapsed && notDisplayedParticipantsCount > 0
!showSingleMemberDMView && memberListCollapsed && notDisplayedParticipantsCount > 0
}

public init(channel: ChatChannel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ class ChatChannelInfoView_Tests: StreamChatTestCase {
// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
}

func test_chatChannelInfoView_directChannelMoreMembersSnapshot() {
// Given
let members = ChannelInfoMockUtils.setupMockMembers(
count: 4,
currentUserId: chatClient.currentUserId!
)
let channel = ChatChannel.mockDMChannel(
name: "Direct channel",
lastActiveMembers: members
)

// When
let view = ChatChannelInfoView(channel: channel)
.applyDefaultSize()

// Then
assertSnapshot(matching: view, as: .image(perceptualPrecision: precision))
}

func test_chatChannelInfoView_directChannelMutedSnapshot() {
// Given
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading