Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### 🐞 Fixed
- Fix tapping on invisible areas on iOS 26 [#868](https://github.com/GetStream/stream-chat-swiftui/pull/868)
- Fix channel view tab bar not hidden on iOS 16.0 [#870](https://github.com/GetStream/stream-chat-swiftui/pull/870)
- Fix mute and unmute commands shown in the composer when removed from Dashboard [#872](https://github.com/GetStream/stream-chat-swiftui/pull/872)

### 🔄 Changed
- Mute and unmute commands are not added by default in the composer [#872](https://github.com/GetStream/stream-chat-swiftui/pull/872)

# [4.80.0](https://github.com/GetStream/stream-chat-swiftui/releases/tag/4.80.0)
_June 17, 2025_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,26 @@ public class DefaultCommandsConfig: CommandsConfig {
var instantCommands = [CommandHandler]()

let channelConfig = channelController.channel?.config
let availableCommands = channelConfig?.commands.map(\.name) ?? []

let giphyEnabled = channelConfig?.commands.first(where: { command in
command.name == "giphy"
}) != nil

if giphyEnabled {
if availableCommands.contains("giphy") {
let giphyCommand = GiphyCommandHandler(commandSymbol: "/giphy")
instantCommands.append(giphyCommand)
}

if channelConfig?.mutesEnabled == true {
if availableCommands.contains("mute") {
let muteCommand = MuteCommandHandler(
channelController: channelController,
commandSymbol: "/mute"
)
instantCommands.append(muteCommand)
}

if availableCommands.contains("unmute") {
let unmuteCommand = UnmuteCommandHandler(
channelController: channelController,
commandSymbol: "/unmute"
)
instantCommands.append(muteCommand)
instantCommands.append(unmuteCommand)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

@testable import StreamChat
@testable import StreamChatSwiftUI
@testable import StreamChatTestTools
import XCTest

class CommandsHandler_Tests: StreamChatTestCase {
Expand Down Expand Up @@ -168,6 +169,39 @@ class CommandsHandler_Tests: StreamChatTestCase {
XCTAssert(displayInfo == nil)
}

func test_defaultCommandsConfig() {
// Given
let channelController = ChatChannelController_Mock.mock()
channelController.channel_mock = .mock(
cid: .unique,
config: .mock(commands: [.init(name: "mute"), .init(name: "unmute"), .init(name: "giphy")])
)
let defaultCommandsHandler = DefaultCommandsConfig()
let handler = defaultCommandsHandler.makeCommandsHandler(with: channelController)

XCTAssertNotNil(handler.canHandleCommand(in: "/mention @user", caretLocation: 10))
XCTAssertNotNil(handler.canHandleCommand(in: "/mute", caretLocation: 0))
XCTAssertNotNil(handler.canHandleCommand(in: "/unmute", caretLocation: 0))
XCTAssertNotNil(handler.canHandleCommand(in: "/giphy", caretLocation: 0))
}

func test_defaultCommandsConfig_whenWithoutMutesCommands() {
// Given
let channelController = ChatChannelController_Mock.mock()
channelController.channel_mock = .mock(
cid: .unique,
config: .mock(commands: [.init(name: "giphy")])
)
let defaultCommandsHandler = DefaultCommandsConfig()
let handler = defaultCommandsHandler.makeCommandsHandler(with: channelController)

XCTAssertNil(handler.canHandleCommand(in: "/mute", caretLocation: 0))
XCTAssertNil(handler.canHandleCommand(in: "/unmute", caretLocation: 0))

XCTAssertNotNil(handler.canHandleCommand(in: "/mention @user", caretLocation: 10))
XCTAssertNotNil(handler.canHandleCommand(in: "/giphy", caretLocation: 0))
}

// MARK: - private

private func command(
Expand Down
Loading