Skip to content

Commit 43561ce

Browse files
committed
refactor: pass channel to createMentionsMiddleware instead of client
1 parent f528274 commit 43561ce

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

src/components/MessageInput/hooks/messageComposer/useMessageComposer.ts

+4-16
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ import {
88
import type { DraftResponse } from 'stream-chat';
99
import { useThreadContext } from '../../../Threads';
1010
import type { StreamMessage } from '../../../../context';
11-
import {
12-
useChannelStateContext,
13-
useChatContext,
14-
useMessageInputContext,
15-
} from '../../../../context';
11+
import { useChannelStateContext, useMessageInputContext } from '../../../../context';
1612

1713
export type UseMessageComposerParams = {
1814
message?: DraftResponse | StreamMessage;
@@ -22,7 +18,6 @@ export type UseMessageComposerParams = {
2218
export const useMessageComposer = ({
2319
textComposerMiddleware,
2420
}: UseMessageComposerParams = {}) => {
25-
const { client } = useChatContext();
2621
const { channel } = useChannelStateContext();
2722
const { message: editedMessage } = useMessageInputContext();
2823
// legacy thread will receive new composer
@@ -58,7 +53,7 @@ export const useMessageComposer = ({
5853
textComposerMiddleware ??
5954
([
6055
createCommandsMiddleware(channel),
61-
createMentionsMiddleware(client),
56+
createMentionsMiddleware(channel),
6257
] as TextComposerMiddleware[]),
6358
);
6459
return composer;
@@ -70,7 +65,7 @@ export const useMessageComposer = ({
7065
textComposerMiddleware ??
7166
([
7267
createCommandsMiddleware(channel),
73-
createMentionsMiddleware(client),
68+
createMentionsMiddleware(channel),
7469
] as TextComposerMiddleware[]),
7570
);
7671
return composer;
@@ -80,14 +75,7 @@ export const useMessageComposer = ({
8075
// should never reach this point
8176
return detachedMesssageComposerRef.current;
8277
}
83-
}, [
84-
cachedEditedMessage,
85-
cachedParentMessage,
86-
channel,
87-
client,
88-
textComposerMiddleware,
89-
thread,
90-
]);
78+
}, [cachedEditedMessage, cachedParentMessage, channel, textComposerMiddleware, thread]);
9179

9280
useEffect(() => {
9381
messageComposer.registerSubscriptions();

0 commit comments

Comments
 (0)