Skip to content

Commit 2088b68

Browse files
Merge branch 'rc' of github.com:GetStream/stream-chat-react into feat/message-composer
2 parents c465f43 + fbbb461 commit 2088b68

File tree

20 files changed

+80
-9
lines changed

20 files changed

+80
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [12.14.0](https://github.com/GetStream/stream-chat-react/compare/v12.13.1...v12.14.0) (2025-04-08)
2+
3+
### Features
4+
5+
* [REACT-218] add MessageBlocked component ([#2675](https://github.com/GetStream/stream-chat-react/issues/2675)) ([0ecd147](https://github.com/GetStream/stream-chat-react/commit/0ecd147264a57921623cf80dad0faa97db203cf3))
6+
17
## [12.13.1](https://github.com/GetStream/stream-chat-react/compare/v12.13.0...v12.13.1) (2025-03-05)
28

39
### Chores

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
"@playwright/test": "^1.42.1",
187187
"@semantic-release/changelog": "^6.0.3",
188188
"@semantic-release/git": "^10.0.1",
189-
"@stream-io/stream-chat-css": "^5.7.2",
189+
"@stream-io/stream-chat-css": "^5.8.0",
190190
"@testing-library/dom": "^10.4.0",
191191
"@testing-library/jest-dom": "^6.6.3",
192192
"@testing-library/react": "^16.2.0",

src/components/Channel/Channel.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ type ChannelPropsForwardedToComponentContext = Pick<
119119
| 'Message'
120120
| 'MessageActions'
121121
| 'MessageBouncePrompt'
122+
| 'MessageBlocked'
122123
| 'MessageDeleted'
123124
| 'MessageListNotifications'
124125
| 'MessageListMainPanel'
@@ -1232,6 +1233,7 @@ const ChannelInner = (
12321233
LoadingIndicator: props.LoadingIndicator,
12331234
Message: props.Message,
12341235
MessageActions: props.MessageActions,
1236+
MessageBlocked: props.MessageBlocked,
12351237
MessageBouncePrompt: props.MessageBouncePrompt,
12361238
MessageDeleted: props.MessageDeleted,
12371239
MessageListNotifications: props.MessageListNotifications,
@@ -1283,6 +1285,7 @@ const ChannelInner = (
12831285
props.DateSeparator,
12841286
props.EditMessageInput,
12851287
props.EmojiPicker,
1288+
props.emojiSearchIndex,
12861289
props.EmptyStateIndicator,
12871290
props.FileUploadIcon,
12881291
props.GiphyPreviewMessage,
@@ -1292,6 +1295,7 @@ const ChannelInner = (
12921295
props.LoadingIndicator,
12931296
props.Message,
12941297
props.MessageActions,
1298+
props.MessageBlocked,
12951299
props.MessageBouncePrompt,
12961300
props.MessageDeleted,
12971301
props.MessageListNotifications,
@@ -1311,11 +1315,14 @@ const ChannelInner = (
13111315
props.QuotedMessage,
13121316
props.QuotedMessagePreview,
13131317
props.QuotedPoll,
1318+
props.reactionOptions,
13141319
props.ReactionSelector,
13151320
props.ReactionsList,
13161321
props.ReactionsListModal,
13171322
props.SendButton,
13181323
props.StartRecordingAudioButton,
1324+
props.StopAIGenerationButton,
1325+
props.StreamedMessageText,
13191326
props.ThreadHead,
13201327
props.ThreadHeader,
13211328
props.ThreadStart,
@@ -1324,10 +1331,6 @@ const ChannelInner = (
13241331
props.UnreadMessagesNotification,
13251332
props.UnreadMessagesSeparator,
13261333
props.VirtualMessage,
1327-
props.StopAIGenerationButton,
1328-
props.StreamedMessageText,
1329-
props.emojiSearchIndex,
1330-
props.reactionOptions,
13311334
],
13321335
);
13331336

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
import clsx from 'clsx';
3+
4+
import { useUserRole } from './hooks/useUserRole';
5+
import { useTranslationContext } from '../../context/TranslationContext';
6+
import { useMessageContext } from '../../context';
7+
8+
export const MessageBlocked = () => {
9+
const { message } = useMessageContext();
10+
const { t } = useTranslationContext('MessageBlocked');
11+
12+
const { isMyMessage } = useUserRole(message);
13+
14+
const messageClasses = clsx(
15+
'str-chat__message str-chat__message-simple str-chat__message--blocked',
16+
message.type,
17+
{
18+
'str-chat__message--me str-chat__message-simple--me': isMyMessage,
19+
'str-chat__message--other': !isMyMessage,
20+
},
21+
);
22+
23+
return (
24+
<div
25+
className={messageClasses}
26+
data-testid='message-blocked-component'
27+
key={message.id}
28+
>
29+
<div className='str-chat__message--blocked-inner'>
30+
{t<string>('Message was blocked by moderation policies')}
31+
</div>
32+
</div>
33+
);
34+
};

src/components/Message/MessageSimple.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import clsx from 'clsx';
44
import { MessageErrorIcon } from './icons';
55
import { MessageBouncePrompt as DefaultMessageBouncePrompt } from '../MessageBounce';
66
import { MessageDeleted as DefaultMessageDeleted } from './MessageDeleted';
7+
import { MessageBlocked as DefaultMessageBlocked } from './MessageBlocked';
78
import { MessageOptions as DefaultMessageOptions } from './MessageOptions';
89
import { MessageRepliesCountButton as DefaultMessageRepliesCountButton } from './MessageRepliesCountButton';
910
import { MessageStatus as DefaultMessageStatus } from './MessageStatus';
1011
import { MessageText } from './MessageText';
1112
import { MessageTimestamp as DefaultMessageTimestamp } from './MessageTimestamp';
1213
import {
1314
areMessageUIPropsEqual,
15+
isMessageBlocked,
1416
isMessageBounced,
1517
isMessageEdited,
1618
messageHasAttachments,
@@ -102,6 +104,7 @@ const MessageSimpleWithContext = (props: MessageSimpleWithContextProps) => {
102104
// TODO: remove this "passthrough" in the next
103105
// major release and use the new default instead
104106
MessageActions = MessageOptions,
107+
MessageBlocked = DefaultMessageBlocked,
105108
MessageDeleted = DefaultMessageDeleted,
106109
MessageBouncePrompt = DefaultMessageBouncePrompt,
107110
MessageRepliesCountButton = DefaultMessageRepliesCountButton,
@@ -126,6 +129,10 @@ const MessageSimpleWithContext = (props: MessageSimpleWithContextProps) => {
126129
return <MessageDeleted message={message} />;
127130
}
128131

132+
if (isMessageBlocked(message)) {
133+
return <MessageBlocked />;
134+
}
135+
129136
const showMetadata = !groupedByUser || endOfGroup;
130137
const showReplyCountButton = !threadList && !!message.reply_count;
131138
const allowRetry = message.status === 'failed' && message.error?.status !== 403;

src/components/Message/utils.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,5 +468,12 @@ export const isMessageBounced = (
468468
(message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_BOUNCE' ||
469469
message.moderation?.action === 'bounce');
470470

471+
export const isMessageBlocked = (
472+
message: Pick<LocalMessage, 'type' | 'moderation' | 'moderation_details'>,
473+
) =>
474+
message.type === 'error' &&
475+
(message.moderation_details?.action === 'MESSAGE_RESPONSE_ACTION_REMOVE' ||
476+
message.moderation?.action === 'remove');
477+
471478
export const isMessageEdited = (message: Pick<LocalMessage, 'message_text_updated_at'>) =>
472479
!!message.message_text_updated_at;

src/context/ComponentContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ export type ComponentContextValue = {
121121
MessageActions?: React.ComponentType;
122122
/** Custom UI component to display the contents of a bounced message modal. Usually it allows to retry, edit, or delete the message. Defaults to and accepts the same props as: [MessageBouncePrompt](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageBounce/MessageBouncePrompt.tsx) */
123123
MessageBouncePrompt?: React.ComponentType<MessageBouncePromptProps>;
124+
/** Custom UI component for a moderation-blocked message, defaults to and accepts same props as: [MessageBlocked](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageBlocked.tsx) */
125+
MessageBlocked?: React.ComponentType;
124126
/** Custom UI component for a deleted message, defaults to and accepts same props as: [MessageDeleted](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageDeleted.tsx) */
125127
MessageDeleted?: React.ComponentType<MessageDeletedProps>;
126128
MessageListMainPanel?: React.ComponentType<PropsWithChildrenOnly>;

src/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Message deleted": "Nachricht gelöscht",
6868
"Message has been successfully flagged": "Nachricht wurde erfolgreich gemeldet",
6969
"Message pinned": "Nachricht angeheftet",
70+
"Message was blocked by moderation policies": "Nachricht wurde durch moderationsrichtlinien blockiert",
7071
"Messages have been marked unread.": "Nachrichten wurden als ungelesen markiert.",
7172
"Missing permissions to upload the attachment": "Fehlende Berechtigungen zum Hochladen des Anhangs",
7273
"Multiple answers": "Mehrere Antworten",

src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Message deleted": "Message deleted",
6868
"Message has been successfully flagged": "Message has been successfully flagged",
6969
"Message pinned": "Message pinned",
70+
"Message was blocked by moderation policies": "Message was blocked by moderation policies",
7071
"Messages have been marked unread.": "Messages have been marked unread.",
7172
"Missing permissions to upload the attachment": "Missing permissions to upload the attachment",
7273
"Multiple answers": "Multiple answers",

src/i18n/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
"Message deleted": "Mensaje eliminado",
6868
"Message has been successfully flagged": "El mensaje se marcó correctamente",
6969
"Message pinned": "Mensaje fijado",
70+
"Message was blocked by moderation policies": "El mensaje fue bloqueado por las políticas de moderación",
7071
"Messages have been marked unread.": "Los mensajes han sido marcados como no leídos.",
7172
"Missing permissions to upload the attachment": "Faltan permisos para subir el archivo adjunto",
7273
"Multiple answers": "Múltiples respuestas",

0 commit comments

Comments
 (0)