Skip to content

Commit c8dff0f

Browse files
committed
refactor: use SendMessageOptions type from stream-chat
1 parent b458810 commit c8dff0f

File tree

8 files changed

+643
-535
lines changed

8 files changed

+643
-535
lines changed

examples/vite/src/App.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ import {
1515
VirtualizedMessageList as MessageList,
1616
Window,
1717
} from 'stream-chat-react';
18+
import { init, SearchIndex } from 'emoji-mart';
19+
import data from '@emoji-mart/data';
20+
21+
init({ data });
1822

1923
const params = new Proxy(new URLSearchParams(window.location.search), {
2024
get: (searchParams, property) => searchParams.get(property as string),
@@ -64,7 +68,7 @@ const App = () => {
6468
showChannelSearch
6569
additionalChannelSearchProps={{ searchForChannels: true }}
6670
/>
67-
<Channel>
71+
<Channel emojiSearchIndex={SearchIndex}>
6872
<Window>
6973
<ChannelHeader Avatar={ChannelAvatar} />
7074
<MessageList returnAllReadData />

examples/vite/yarn.lock

+619-515
Large diffs are not rendered by default.

src/components/Channel/Channel.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {
2424
Message,
2525
MessageResponse,
2626
SendMessageAPIResponse,
27+
SendMessageOptions,
2728
Channel as StreamChannel,
2829
StreamChat,
2930
Thread,
@@ -91,7 +92,6 @@ import type {
9192
CustomTrigger,
9293
GiphyVersions,
9394
ImageAttachmentSizeHandler,
94-
SendMessageOptions,
9595
UpdateMessageOptions,
9696
VideoAttachmentSizeHandler,
9797
} from '../../types/types';

src/components/MessageInput/MessageInput.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ import { useComponentContext } from '../../context/ComponentContext';
1414
import { MessageInputContextProvider } from '../../context/MessageInputContext';
1515
import { DialogManagerProvider } from '../../context';
1616

17-
import type { Channel, Message, SendFileAPIResponse } from 'stream-chat';
17+
import type {
18+
Channel,
19+
Message,
20+
SendFileAPIResponse,
21+
SendMessageOptions,
22+
} from 'stream-chat';
1823

1924
import type { BaseLocalAttachmentMetadata, LocalAttachmentUploadMetadata } from './types';
2025
import type { SearchQueryParams } from '../ChannelSearch/hooks/useChannelSearch';
2126
import type { MessageToSend } from '../../context/ChannelActionContext';
22-
import type { CustomTrigger, SendMessageOptions, UnknownType } from '../../types/types';
27+
import type { CustomTrigger, UnknownType } from '../../types/types';
2328
import type { URLEnrichmentConfig } from './hooks/useLinkPreviews';
2429
import type { CustomAudioRecordingConfig } from '../MediaRecorder';
2530
import { useMessageComposer } from './hooks/messageComposer/useMessageComposer';

src/components/MessageInput/hooks/useMessageInputState/useMessageInputState.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import type { RecordingController } from '../../../MediaRecorder/hooks/useMediaR
1515
import { useMediaRecorder } from '../../../MediaRecorder/hooks/useMediaRecorder';
1616
import type { LinkPreviewMap, LocalAttachment } from '../../types';
1717
import { LinkPreviewState, SetLinkPreviewMode } from '../../types';
18-
import type { Attachment, Message, UserResponse } from 'stream-chat';
18+
import type { Attachment, Message, SendMessageOptions, UserResponse } from 'stream-chat';
1919

2020
import type { MessageInputProps } from '../../MessageInput';
2121

22-
import type { CustomTrigger, SendMessageOptions } from '../../../../types/types';
22+
import type { CustomTrigger } from '../../../../types/types';
2323
import { mergeDeep } from '../../../../utils/mergeDeep';
2424
import type { MessageInputState } from './initMessageInputState';
2525
import { initState, makeEmptyMessageInputState } from './initMessageInputState';

src/components/MessageInput/hooks/useSubmitHandler.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ import { useChannelStateContext } from '../../../context/ChannelStateContext';
44
import { useTranslationContext } from '../../../context/TranslationContext';
55
import { type LinkPreviewMap, LinkPreviewState, type LocalAttachment } from '../types';
66

7-
import type { Attachment, Message, UpdatedMessage, UserResponse } from 'stream-chat';
7+
import type {
8+
Attachment,
9+
Message,
10+
SendMessageOptions,
11+
UpdatedMessage,
12+
UserResponse,
13+
} from 'stream-chat';
814

915
import type {
1016
MessageInputReducerAction,
1117
MessageInputState,
1218
} from './useMessageInputState';
1319
import type { MessageInputProps } from '../MessageInput';
1420

15-
import type { CustomTrigger, SendMessageOptions } from '../../../types/types';
21+
import type { CustomTrigger } from '../../../types/types';
1622
import type { EnrichURLsController } from './useLinkPreviews';
1723

1824
export type PrepareMessageParams = Pick<

src/context/ChannelActionContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type {
77
ErrorFromResponse,
88
Message,
99
MessageResponse,
10+
SendMessageOptions,
1011
UpdatedMessage,
1112
UpdateMessageAPIResponse,
1213
UserResponse,
@@ -19,7 +20,6 @@ import type { CustomMentionHandler } from '../components/Message/hooks/useMentio
1920

2021
import type {
2122
ChannelUnreadUiState,
22-
SendMessageOptions,
2323
UnknownType,
2424
UpdateMessageOptions,
2525
} from '../types/types';

src/types/types.ts

-11
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,6 @@ export type VideoAttachmentSizeHandler = (
117117

118118
export type ChannelUnreadUiState = Omit<ValuesType<StreamChannelState['read']>, 'user'>;
119119

120-
// todo: fix export from stream-chat - for some reason not exported
121-
export type SendMessageOptions = {
122-
force_moderation?: boolean;
123-
is_pending_message?: boolean;
124-
keep_channel_hidden?: boolean;
125-
pending?: boolean;
126-
pending_message_metadata?: Record<string, string>;
127-
skip_enrich_url?: boolean;
128-
skip_push?: boolean;
129-
};
130-
131120
// todo: fix export from stream-chat - for some reason not exported
132121
export type UpdateMessageOptions = {
133122
skip_enrich_url?: boolean;

0 commit comments

Comments
 (0)