Skip to content

Commit e2a7df0

Browse files
fixed bug with the mute command
1 parent 49e98e9 commit e2a7df0

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/CommandsHandler.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public protocol CommandHandler {
1515
/// Display info for the command.
1616
var displayInfo: CommandDisplayInfo? { get }
1717

18+
/// Whether execution of the command replaces sending of a message.
19+
var replacesMessageSent: Bool { get }
20+
1821
/// Checks whether the command can be handled.
1922
/// - Parameters:
2023
/// - text: the user entered text.
@@ -68,6 +71,10 @@ public protocol CommandHandler {
6871
/// Default implementations.
6972
extension CommandHandler {
7073

74+
public var replacesMessageSent: Bool {
75+
false
76+
}
77+
7178
public func executeOnMessageSent(
7279
composerCommand: ComposerCommand,
7380
completion: @escaping (Error?) -> Void

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/InstantCommands/InstantCommandsView.swift

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,18 @@ struct InstantCommandsView: View {
4444
Spacer()
4545
}
4646
.standardPadding()
47-
.onTapGesture {
48-
let instantCommand = ComposerCommand(
49-
id: command.id,
50-
typingSuggestion: TypingSuggestion.empty,
51-
displayInfo: command.displayInfo
52-
)
53-
commandSelected(instantCommand)
54-
}
47+
.highPriorityGesture(
48+
TapGesture()
49+
.onEnded { _ in
50+
let instantCommand = ComposerCommand(
51+
id: command.id,
52+
typingSuggestion: TypingSuggestion.empty,
53+
displayInfo: command.displayInfo,
54+
replacesMessageSent: command.replacesMessageSent
55+
)
56+
commandSelected(instantCommand)
57+
}
58+
)
5559
}
5660
}
5761
}

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/InstantCommands/TwoStepMentionCommand.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ public class TwoStepMentionCommand: CommandHandler {
131131
return mentionsCommandHandler.showSuggestions(for: updated)
132132
}
133133

134+
public var replacesMessageSent: Bool {
135+
true
136+
}
137+
134138
public func executeOnMessageSent(
135139
composerCommand: ComposerCommand,
136140
completion: @escaping (Error?) -> Void

Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions/Mentions/MentionUsersView.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,11 @@ public struct MentionUserView: View {
6767
.foregroundColor(colors.tintColor)
6868
}
6969
.standardPadding()
70-
.onTapGesture {
71-
userSelected(user)
72-
}
70+
.highPriorityGesture(
71+
TapGesture()
72+
.onEnded { _ in
73+
userSelected(user)
74+
}
75+
)
7376
}
7477
}

0 commit comments

Comments
 (0)