Skip to content

Commit d248440

Browse files
committed
fix: autocomplete input re-render on received message
1 parent c755738 commit d248440

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

package/src/components/AutoCompleteInput/AutoCompleteInput.tsx

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ import { I18nManager, StyleSheet, TextInput, TextInputProps } from 'react-native
33

44
import throttle from 'lodash/throttle';
55

6-
import {
7-
ChannelContextValue,
8-
useChannelContext,
9-
} from '../../contexts/channelContext/ChannelContext';
106
import {
117
MessageInputContextValue,
128
useMessageInputContext,
@@ -53,22 +49,22 @@ const isCommand = (text: string) => text[0] === '/' && text.split(' ').length <=
5349

5450
type AutoCompleteInputPropsWithContext<
5551
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
56-
> = Pick<ChannelContextValue<StreamChatGenerics>, 'giphyEnabled'> &
57-
Pick<
58-
MessageInputContextValue<StreamChatGenerics>,
59-
| 'additionalTextInputProps'
60-
| 'autoCompleteSuggestionsLimit'
61-
| 'giphyActive'
62-
| 'maxMessageLength'
63-
| 'mentionAllAppUsersEnabled'
64-
| 'mentionAllAppUsersQuery'
65-
| 'numberOfLines'
66-
| 'onChange'
67-
| 'setGiphyActive'
68-
| 'setInputBoxRef'
69-
| 'text'
70-
| 'triggerSettings'
71-
> &
52+
> = Pick<
53+
MessageInputContextValue<StreamChatGenerics>,
54+
| 'additionalTextInputProps'
55+
| 'autoCompleteSuggestionsLimit'
56+
| 'giphyActive'
57+
| 'giphyEnabled'
58+
| 'maxMessageLength'
59+
| 'mentionAllAppUsersEnabled'
60+
| 'mentionAllAppUsersQuery'
61+
| 'numberOfLines'
62+
| 'onChange'
63+
| 'setGiphyActive'
64+
| 'setInputBoxRef'
65+
| 'text'
66+
| 'triggerSettings'
67+
> &
7268
Pick<
7369
SuggestionsContextValue<StreamChatGenerics>,
7470
'closeSuggestions' | 'openSuggestions' | 'updateSuggestions'
@@ -484,8 +480,8 @@ export const AutoCompleteInput = <
484480
>(
485481
props: AutoCompleteInputProps<StreamChatGenerics>,
486482
) => {
487-
const { giphyEnabled } = useChannelContext<StreamChatGenerics>();
488483
const {
484+
giphyEnabled,
489485
additionalTextInputProps,
490486
autoCompleteSuggestionsLimit,
491487
giphyActive,

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export type LocalMessageInputContext<
125125
url: string;
126126
};
127127
};
128+
giphyEnabled: boolean;
128129
closeAttachmentPicker: () => void;
129130
/** The time at which the active cooldown will end */
130131
cooldownEndsAt: Date;
@@ -1446,6 +1447,7 @@ export const MessageInputProvider = <
14461447
cooldownEndsAt,
14471448
fileUploads,
14481449
giphyActive,
1450+
giphyEnabled,
14491451
imageUploads,
14501452
inputBoxRef,
14511453
isValidMessage,

package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export const useCreateMessageInputContext = <
4141
FileUploadPreview,
4242
fileUploads,
4343
giphyActive,
44+
giphyEnabled,
4445
handleAttachButtonPress,
4546
hasCameraPicker,
4647
hasCommands,
@@ -164,6 +165,7 @@ export const useCreateMessageInputContext = <
164165
FileUploadPreview,
165166
fileUploads,
166167
giphyActive,
168+
giphyEnabled,
167169
handleAttachButtonPress,
168170
hasCameraPicker,
169171
hasCommands,
@@ -246,6 +248,7 @@ export const useCreateMessageInputContext = <
246248
editingdep,
247249
fileUploadsValue,
248250
giphyActive,
251+
giphyEnabled,
249252
imageUploadsValue,
250253
maxMessageLength,
251254
mentionedUsersLength,

0 commit comments

Comments
 (0)