Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ public class ChatChannelInfoViewModel: ObservableObject, ChatChannelControllerDe
@Published public var addUsersShown = false

public var shouldShowLeaveConversationButton: Bool {
channel.ownCapabilities.contains(.deleteChannel)
|| !channel.isDirectMessageChannel
if channel.isDirectMessageChannel {
return channel.ownCapabilities.contains(.deleteChannel)
} else {
return channel.ownCapabilities.contains(.leaveChannel)
}
}

public var canRenameChannel: Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension ChannelAction {

actions.append(viewInfo)

if !channel.isDirectMessageChannel, let userId = chatClient.currentUserId {
if !channel.isDirectMessageChannel, channel.ownCapabilities.contains(.leaveChannel), let userId = chatClient.currentUserId {
let leaveGroup = leaveGroup(
for: channel,
chatClient: chatClient,
Expand Down
6 changes: 3 additions & 3 deletions StreamChatSwiftUI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3818,10 +3818,10 @@
};
84E95A75284A486600699FD3 /* XCRemoteSwiftPackageReference "stream-chat-swift" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/GetStream/stream-chat-swift.git";
repositoryURL = "https://github.com/bpollman/stream-chat-swift.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.65.0;
branch = "update-dm-mocks";
kind = branch;
};
};
E3A1C01A282BAC66002D1E26 /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,21 @@ class ChatChannelInfoViewModel_Tests: StreamChatTestCase {
XCTAssert(leaveButton == true)
}

func test_chatChannelInfoVM_leaveButtonHiddenInGroup() {
// Given
let channel = mockGroup(with: 5, updateCapabilities: false)
let viewModel = ChatChannelInfoViewModel(channel: channel)

// When
let leaveButton = viewModel.shouldShowLeaveConversationButton

// Then
XCTAssert(leaveButton == false)
}

func test_chatChannelInfoVM_leaveButtonShownInDM() {
// Given
let channel = ChatChannel.mock(
cid: .unique,
let channel = ChatChannel.mockDMChannel(
name: "Test",
ownCapabilities: [.deleteChannel]
)
Expand Down Expand Up @@ -262,6 +273,7 @@ class ChatChannelInfoViewModel_Tests: StreamChatTestCase {
if updateCapabilities {
capabilities.insert(.updateChannel)
capabilities.insert(.deleteChannel)
capabilities.insert(.leaveChannel)
}
let channel = ChatChannel.mock(
cid: cid,
Expand Down
Loading