Skip to content

Commit 658b372

Browse files
committed
fix: issue with sending message anyway and edit message when moderation bounced it
1 parent f8c9b9a commit 658b372

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,6 +1433,8 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
14331433
...message,
14341434
attachments,
14351435
text: patchMessageTextCommand(text ?? '', mentioned_users ?? []),
1436+
// We cannot send an error message, so we convert it to a regular message.
1437+
type: message.type === 'error' ? 'regular' : message.type,
14361438
} as StreamMessage;
14371439

14381440
let messageResponse = {} as SendMessageAPIResponse;

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ export const MessageInputProvider = ({
603603
return;
604604
}
605605

606+
// MODERATION: This is for the case where the message is of type 'error' and if you try to edit it, it will throw an error.
606607
if (editedMessage && editedMessage.type !== 'error') {
607608
try {
608609
clearEditingState();
@@ -629,6 +630,10 @@ export const MessageInputProvider = ({
629630
message,
630631
options: sendOptions,
631632
});
633+
// Even though we edit, but we eventually send the message as a regular message, so we need to clear the editing state.
634+
if (editedMessage) {
635+
clearEditingState();
636+
}
632637
} catch (error) {
633638
throw new Error('Error while sending message');
634639
}

0 commit comments

Comments
 (0)