File tree Expand file tree Collapse file tree 4 files changed +29
-11
lines changed
Sources/StreamChatSwiftUI/ChatChannel/Composer/Suggestions Expand file tree Collapse file tree 4 files changed +29
-11
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ public protocol CommandHandler {
15
15
/// Display info for the command.
16
16
var displayInfo : CommandDisplayInfo ? { get }
17
17
18
+ /// Whether execution of the command replaces sending of a message.
19
+ var replacesMessageSent : Bool { get }
20
+
18
21
/// Checks whether the command can be handled.
19
22
/// - Parameters:
20
23
/// - text: the user entered text.
@@ -68,6 +71,10 @@ public protocol CommandHandler {
68
71
/// Default implementations.
69
72
extension CommandHandler {
70
73
74
+ public var replacesMessageSent : Bool {
75
+ false
76
+ }
77
+
71
78
public func executeOnMessageSent(
72
79
composerCommand: ComposerCommand ,
73
80
completion: @escaping ( Error ? ) -> Void
Original file line number Diff line number Diff line change @@ -44,14 +44,18 @@ struct InstantCommandsView: View {
44
44
Spacer ( )
45
45
}
46
46
. 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
+ )
55
59
}
56
60
}
57
61
}
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ public class TwoStepMentionCommand: CommandHandler {
131
131
return mentionsCommandHandler. showSuggestions ( for: updated)
132
132
}
133
133
134
+ public var replacesMessageSent : Bool {
135
+ true
136
+ }
137
+
134
138
public func executeOnMessageSent(
135
139
composerCommand: ComposerCommand ,
136
140
completion: @escaping ( Error ? ) -> Void
Original file line number Diff line number Diff line change @@ -67,8 +67,11 @@ public struct MentionUserView: View {
67
67
. foregroundColor ( colors. tintColor)
68
68
}
69
69
. standardPadding ( )
70
- . onTapGesture {
71
- userSelected ( user)
72
- }
70
+ . highPriorityGesture (
71
+ TapGesture ( )
72
+ . onEnded { _ in
73
+ userSelected ( user)
74
+ }
75
+ )
73
76
}
74
77
}
You can’t perform that action at this time.
0 commit comments