File tree Expand file tree Collapse file tree 7 files changed +62
-3
lines changed
Sources/StreamChatSwiftUI
StreamChatSwiftUITests/Tests/ChatChannel Expand file tree Collapse file tree 7 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
7
7
- Jump to a message that is not on the first page
8
8
- Jump to a message in a thread
9
9
- Bi-directional scrolling of the message list
10
+ - Handling of bounced messages
10
11
11
12
### 🐞 Fixed
12
13
- Some links not being rendered correctly
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
60
60
61
61
public var body : some View {
62
62
HStack ( alignment: . bottom) {
63
- if message. type == . system || message. type == . error {
63
+ if message. type == . system || ( message. type == . error && message . isBounced == false ) {
64
64
factory. makeSystemMessageView ( message: message)
65
65
} else {
66
66
if message. isRightAligned {
@@ -105,7 +105,7 @@ public struct MessageContainerView<Factory: ViewFactory>: View {
105
105
)
106
106
: nil
107
107
108
- message. localState == . sendingFailed ? SendFailureIndicator ( ) : nil
108
+ ( message. localState == . sendingFailed || message . isBounced ) ? SendFailureIndicator ( ) : nil
109
109
}
110
110
)
111
111
. background (
Original file line number Diff line number Diff line change @@ -42,6 +42,23 @@ extension MessageAction {
42
42
onError: onError
43
43
)
44
44
return messageActions
45
+ } else if message. isBounced {
46
+ let title = MessageAction (
47
+ title: L10n . Message. Bounce. title,
48
+ iconName: " exclamationmark.octagon.fill " ,
49
+ action: { } ,
50
+ confirmationPopup: nil ,
51
+ isDestructive: false
52
+ )
53
+ messageActions = messageNotSentActions (
54
+ for: message,
55
+ channel: channel,
56
+ chatClient: chatClient,
57
+ onFinish: onFinish,
58
+ onError: onError
59
+ )
60
+ messageActions. insert ( title, at: 0 )
61
+ return messageActions
45
62
}
46
63
47
64
if channel. config. quotesEnabled {
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ public struct ReactionsOverlayView<Factory: ViewFactory>: View {
132
132
x: messageOriginX ( proxy: reader)
133
133
)
134
134
. overlay (
135
- channel. config. reactionsEnabled ?
135
+ ( channel. config. reactionsEnabled && !messageDisplayInfo . message . isBounced ) ?
136
136
factory. makeReactionsContentView (
137
137
message: viewModel. message,
138
138
contentRect: messageDisplayInfo. frame,
Original file line number Diff line number Diff line change @@ -300,6 +300,10 @@ internal enum L10n {
300
300
internal static var confirmationTitle : String { L10n . tr ( " Localizable " , " message.actions.flag.confirmation-title " ) }
301
301
}
302
302
}
303
+ internal enum Bounce {
304
+ /// Message was bounced
305
+ internal static var title : String { L10n . tr ( " Localizable " , " message.bounce.title " ) }
306
+ }
303
307
internal enum Cell {
304
308
/// Pinned by
305
309
internal static var pinnedBy : String { L10n . tr ( " Localizable " , " message.cell.pinnedBy " ) }
Original file line number Diff line number Diff line change 106
106
"message.search.title" = "Search";
107
107
"message.search.cancel" = "Cancel";
108
108
109
+ "message.bounce.title" = "Message was bounced";
110
+
109
111
"current-selection" = "%d of %d";
110
112
111
113
"attachment.max-size-exceeded" = "Attachment size exceed the limit.";
Original file line number Diff line number Diff line change @@ -174,4 +174,39 @@ class MessageActions_Tests: StreamChatTestCase {
174
174
XCTAssert ( messageActions [ 0 ] . title == " Edit Message " )
175
175
XCTAssert ( messageActions [ 1 ] . title == " Delete Message " )
176
176
}
177
+
178
+ func test_messageActions_bouncedMessage( ) {
179
+ // Given
180
+ let channel = ChatChannel . mockDMChannel ( )
181
+ let moderationDetails = MessageModerationDetails (
182
+ originalText: " Some text " ,
183
+ action: . bounce
184
+ )
185
+ let message = ChatMessage . mock (
186
+ id: . unique,
187
+ cid: channel. cid,
188
+ text: " Test " ,
189
+ author: . mock( id: chatClient. currentUserId!) ,
190
+ isBounced: true ,
191
+ moderationsDetails: moderationDetails
192
+ )
193
+ let factory = DefaultViewFactory . shared
194
+
195
+ // When
196
+ let messageActions = MessageAction . defaultActions (
197
+ factory: factory,
198
+ for: message,
199
+ channel: channel,
200
+ chatClient: chatClient,
201
+ onFinish: { _ in } ,
202
+ onError: { _ in }
203
+ )
204
+
205
+ // Then
206
+ XCTAssert ( messageActions. count == 4 )
207
+ XCTAssert ( messageActions [ 0 ] . title == " Message was bounced " )
208
+ XCTAssert ( messageActions [ 1 ] . title == " Resend " )
209
+ XCTAssert ( messageActions [ 2 ] . title == " Edit Message " )
210
+ XCTAssert ( messageActions [ 3 ] . title == " Delete Message " )
211
+ }
177
212
}
You can’t perform that action at this time.
0 commit comments