Skip to content

Commit 6dab139

Browse files
committed
feat: add error handling for thread search in MessageThreadReplyInChannelButtonIndicator
1 parent 39831cc commit 6dab139

File tree

15 files changed

+34
-4
lines changed

15 files changed

+34
-4
lines changed

src/components/Message/MessageSimple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { MessageText } from './MessageText';
1212
import { MessageTimestamp as DefaultMessageTimestamp } from './MessageTimestamp';
1313
import { StreamedMessageText as DefaultStreamedMessageText } from './StreamedMessageText';
1414
import { isDateSeparatorMessage } from '../MessageList';
15-
import { MessageIsThreadReplyInChannelButtonIndicator as DefaultMessageIsThreadReplyInChannelButtonIndicator } from './MessageIsThreadReplyInChannelButtonIndicator';
15+
import { MessageThreadReplyInChannelButtonIndicator as DefaultMessageIsThreadReplyInChannelButtonIndicator } from './MessageThreadReplyInChannelButtonIndicator';
1616
import {
1717
areMessageUIPropsEqual,
1818
isMessageBlocked,

src/components/Message/MessageIsThreadReplyInChannelButtonIndicator.tsx renamed to src/components/Message/MessageThreadReplyInChannelButtonIndicator.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ import { formatMessage } from 'stream-chat';
44
import {
55
useChannelActionContext,
66
useChannelStateContext,
7+
useChatContext,
78
useMessageContext,
89
useTranslationContext,
910
} from '../../context';
1011

11-
export const MessageIsThreadReplyInChannelButtonIndicator = () => {
12+
export const MessageThreadReplyInChannelButtonIndicator = () => {
13+
const { client } = useChatContext();
1214
const { t } = useTranslationContext();
1315
const { channel } = useChannelStateContext();
1416
const { openThread } = useChannelActionContext();
@@ -20,8 +22,23 @@ export const MessageIsThreadReplyInChannelButtonIndicator = () => {
2022
.getClient()
2123
.search({ cid: channel.cid }, { id: message.parent_id })
2224
.then(({ results }) => {
23-
if (!results.length) return;
25+
if (!results.length) {
26+
throw new Error('Thread has not been found');
27+
}
2428
parentMessageRef.current = formatMessage(results[0].message);
29+
})
30+
.catch((error: Error) => {
31+
client.notifications.addError({
32+
message: t<string>('Thread has not been found'),
33+
options: {
34+
originalError: error,
35+
type: 'api:message:search:not-found',
36+
},
37+
origin: {
38+
context: { threadReply: message },
39+
emitter: 'MessageThreadReplyInChannelButtonIndicator',
40+
},
41+
});
2542
});
2643

2744
useEffect(() => {
@@ -60,6 +77,7 @@ export const MessageIsThreadReplyInChannelButtonIndicator = () => {
6077
}
6178
openThread(parentMessageRef.current);
6279
}}
80+
type='button'
6381
>
6482
{t<string>('Thread reply')}
6583
</button>

src/context/ComponentContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export type ComponentContextValue = {
124124
MessageBlocked?: React.ComponentType;
125125
/** 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) */
126126
MessageDeleted?: React.ComponentType<MessageDeletedProps>;
127-
/** Custom UI component for an indicator that a message is a thread reply sent to channel list: [MessageIsThreadReplyInChannelButtonIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageIsThreadReplyInChannelButtonIndicator.tsx) */
127+
/** Custom UI component for an indicator that a message is a thread reply sent to channel list: [MessageThreadReplyInChannelButtonIndicator](https://github.com/GetStream/stream-chat-react/blob/master/src/components/Message/MessageIsThreadReplyInChannelButtonIndicator.tsx) */
128128
MessageIsThreadReplyInChannelButtonIndicator?: React.ComponentType;
129129
MessageListMainPanel?: React.ComponentType<PropsWithChildrenOnly>;
130130
/** Custom UI component that displays message and connection status notifications in the `MessageList`, defaults to and accepts same props as [DefaultMessageListNotifications](https://github.com/GetStream/stream-chat-react/blob/master/src/components/MessageList/MessageListNotifications.tsx) */

src/i18n/de.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"This message did not meet our content guidelines": "Diese Nachricht entsprach nicht unseren Inhaltsrichtlinien",
121121
"This message was deleted...": "Diese Nachricht wurde gelöscht...",
122122
"Thread": "Thread",
123+
"Thread has not been found": "Thread wurde nicht gefunden",
123124
"Thread reply": "Thread-Antwort",
124125
"To start recording, allow the camera access in your browser": "Um mit der Aufnahme zu beginnen, erlauben Sie den Zugriff auf die Kamera in Ihrem Browser",
125126
"To start recording, allow the microphone access in your browser": "Um mit der Aufnahme zu beginnen, erlauben Sie den Zugriff auf das Mikrofon in Ihrem Browser",

src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"This message did not meet our content guidelines": "This message did not meet our content guidelines",
121121
"This message was deleted...": "This message was deleted...",
122122
"Thread": "Thread",
123+
"Thread has not been found": "Thread has not been found",
123124
"Thread reply": "Thread reply",
124125
"To start recording, allow the camera access in your browser": "To start recording, allow the camera access in your browser",
125126
"To start recording, allow the microphone access in your browser": "To start recording, allow the microphone access in your browser",

src/i18n/es.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"This message did not meet our content guidelines": "Este mensaje no cumple con nuestras directrices de contenido",
123123
"This message was deleted...": "Este mensaje fue eliminado...",
124124
"Thread": "Hilo",
125+
"Thread has not been found": "No se ha encontrado el hilo",
125126
"Thread reply": "Respuesta en hilo",
126127
"To start recording, allow the camera access in your browser": "Para comenzar a grabar, permita el acceso a la cámara en su navegador",
127128
"To start recording, allow the microphone access in your browser": "Para comenzar a grabar, permita el acceso al micrófono en su navegador",

src/i18n/fr.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"This message did not meet our content guidelines": "Ce message ne respecte pas nos directives de contenu",
123123
"This message was deleted...": "Ce message a été supprimé...",
124124
"Thread": "Fil de discussion",
125+
"Thread has not been found": "Le fil de discussion n'a pas été trouvé",
125126
"Thread reply": "Réponse dans le fil",
126127
"To start recording, allow the camera access in your browser": "Pour commencer l'enregistrement, autorisez l'accès à la caméra dans votre navigateur",
127128
"To start recording, allow the microphone access in your browser": "Pour commencer l'enregistrement, autorisez l'accès au microphone dans votre navigateur",

src/i18n/hi.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
"This message did not meet our content guidelines": "यह संदेश हमारे सामग्री दिशानिर्देशों के अनुरूप नहीं था",
122122
"This message was deleted...": "मैसेज हटा दिया गया",
123123
"Thread": "रिप्लाई थ्रेड",
124+
"Thread has not been found": "थ्रेड नहीं मिला",
124125
"Thread reply": "थ्रेड में उत्तर",
125126
"To start recording, allow the camera access in your browser": "रिकॉर्डिंग शुरू करने के लिए, अपने ब्राउज़र में कैमरा तक पहुँच दें",
126127
"To start recording, allow the microphone access in your browser": "रिकॉर्डिंग शुरू करने के लिए, अपने ब्राउज़र में माइक्रोफ़ोन तक पहुँच दें",

src/i18n/it.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"This message did not meet our content guidelines": "Questo messaggio non soddisfa le nostre linee guida sui contenuti",
123123
"This message was deleted...": "Questo messaggio è stato cancellato...",
124124
"Thread": "Discussione",
125+
"Thread has not been found": "Discussione non trovata",
125126
"Thread reply": "Risposta nella discussione",
126127
"To start recording, allow the camera access in your browser": "Per iniziare a registrare, consenti l'accesso alla fotocamera nel tuo browser",
127128
"To start recording, allow the microphone access in your browser": "Per iniziare a registrare, consenti l'accesso al microfono nel tuo browser",

src/i18n/ja.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@
118118
"This message did not meet our content guidelines": "このメッセージはコンテンツガイドラインに適合していません",
119119
"This message was deleted...": "このメッセージは削除されました...",
120120
"Thread": "スレッド",
121+
"Thread has not been found": "スレッドが見つかりませんでした",
121122
"Thread reply": "スレッドの返信",
122123
"To start recording, allow the camera access in your browser": "録音を開始するには、ブラウザーでカメラへのアクセスを許可してください",
123124
"To start recording, allow the microphone access in your browser": "録音を開始するには、ブラウザーでマイクロフォンへのアクセスを許可してください",

0 commit comments

Comments
 (0)