Skip to content

Commit 9ba3644

Browse files
committed
fix: cleanup for the attachment manager
1 parent 3ac8e8b commit 9ba3644

File tree

6 files changed

+21
-67
lines changed

6 files changed

+21
-67
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
489489
AutoCompleteSuggestionItem = AutoCompleteSuggestionItemDefault,
490490
AutoCompleteSuggestionList = AutoCompleteSuggestionListDefault,
491491

492-
autoCompleteSuggestionsLimit,
493492
Card = CardDefault,
494493
CardCover,
495494
CardFooter,
@@ -554,7 +553,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
554553
ImageReloadIndicator = ImageReloadIndicatorDefault,
555554
ImageUploadPreview = ImageUploadPreviewDefault,
556555
initialScrollToFirstUnreadMessage = false,
557-
initialValue,
558556
InlineDateSeparator = InlineDateSeparatorDefault,
559557
InlineUnreadIndicator = InlineUnreadIndicatorDefault,
560558
Input,
@@ -576,8 +574,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
576574
markReadOnMount = true,
577575
maxNumberOfFiles = 10,
578576
maxTimeBetweenGroupedMessages,
579-
mentionAllAppUsersEnabled = false,
580-
mentionAllAppUsersQuery,
581577
Message = MessageDefault,
582578
MessageActionList = MessageActionListDefault,
583579
MessageActionListItem = MessageActionListItemDefault,
@@ -654,7 +650,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
654650
TypingIndicator = TypingIndicatorDefault,
655651
TypingIndicatorContainer = TypingIndicatorContainerDefault,
656652
UnreadMessagesNotification = UnreadMessagesNotificationDefault,
657-
UploadProgressIndicator = AttachmentUploadProgressIndicatorDefault,
653+
AttachmentUploadProgressIndicator = AttachmentUploadProgressIndicatorDefault,
658654
UrlPreview = CardDefault,
659655
VideoAttachmentUploadPreview = VideoAttachmentUploadPreviewDefault,
660656
VideoThumbnail = VideoThumbnailDefault,
@@ -1687,6 +1683,7 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
16871683
asyncMessagesMultiSendEnabled,
16881684
asyncMessagesSlideToCancelDistance,
16891685
AttachButton,
1686+
AttachmentUploadProgressIndicator,
16901687
AudioAttachmentUploadPreview,
16911688
AudioRecorder,
16921689
audioRecordingEnabled,
@@ -1697,7 +1694,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
16971694
AutoCompleteSuggestionHeader,
16981695
AutoCompleteSuggestionItem,
16991696
AutoCompleteSuggestionList,
1700-
autoCompleteSuggestionsLimit,
17011697
channelId,
17021698
clearEditingState,
17031699
CommandInput,
@@ -1717,15 +1713,12 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
17171713
hasImagePicker,
17181714
ImageAttachmentUploadPreview,
17191715
ImageUploadPreview,
1720-
initialValue,
17211716
Input,
17221717
InputButtons,
17231718
InputEditingStateHeader,
17241719
InputReplyStateHeader,
17251720
isCommandUIEnabled,
17261721
maxNumberOfFiles,
1727-
mentionAllAppUsersEnabled,
1728-
mentionAllAppUsersQuery,
17291722
MoreOptionsButton,
17301723
openPollCreationDialog,
17311724
SendButton,
@@ -1735,7 +1728,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
17351728
ShowThreadMessageInChannelButton,
17361729
StartAudioRecordingButton,
17371730
StopMessageStreamingButton,
1738-
UploadProgressIndicator,
17391731
VideoAttachmentUploadPreview,
17401732
});
17411733

package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const useCreateInputMessageInputContext = ({
99
asyncMessagesMultiSendEnabled,
1010
asyncMessagesSlideToCancelDistance,
1111
AttachButton,
12+
AttachmentUploadProgressIndicator,
1213
AudioAttachmentUploadPreview,
1314
AudioRecorder,
1415
audioRecordingEnabled,
@@ -19,7 +20,6 @@ export const useCreateInputMessageInputContext = ({
1920
AutoCompleteSuggestionHeader,
2021
AutoCompleteSuggestionItem,
2122
AutoCompleteSuggestionList,
22-
autoCompleteSuggestionsLimit,
2323
channelId,
2424
clearEditingState,
2525
CommandInput,
@@ -39,15 +39,12 @@ export const useCreateInputMessageInputContext = ({
3939
hasImagePicker,
4040
ImageAttachmentUploadPreview,
4141
ImageUploadPreview,
42-
initialValue,
4342
Input,
4443
InputButtons,
4544
InputEditingStateHeader,
4645
InputReplyStateHeader,
4746
isCommandUIEnabled,
4847
maxNumberOfFiles,
49-
mentionAllAppUsersEnabled,
50-
mentionAllAppUsersQuery,
5148
MoreOptionsButton,
5249
openPollCreationDialog,
5350
SendButton,
@@ -58,7 +55,6 @@ export const useCreateInputMessageInputContext = ({
5855
ShowThreadMessageInChannelButton,
5956
StartAudioRecordingButton,
6057
StopMessageStreamingButton,
61-
UploadProgressIndicator,
6258
VideoAttachmentUploadPreview,
6359
}: InputMessageInputContextValue & {
6460
/**
@@ -76,6 +72,7 @@ export const useCreateInputMessageInputContext = ({
7672
asyncMessagesMultiSendEnabled,
7773
asyncMessagesSlideToCancelDistance,
7874
AttachButton,
75+
AttachmentUploadProgressIndicator,
7976
AudioAttachmentUploadPreview,
8077
AudioRecorder,
8178
audioRecordingEnabled,
@@ -86,7 +83,6 @@ export const useCreateInputMessageInputContext = ({
8683
AutoCompleteSuggestionHeader,
8784
AutoCompleteSuggestionItem,
8885
AutoCompleteSuggestionList,
89-
autoCompleteSuggestionsLimit,
9086
clearEditingState,
9187
CommandInput,
9288
CommandsButton,
@@ -105,15 +101,12 @@ export const useCreateInputMessageInputContext = ({
105101
hasImagePicker,
106102
ImageAttachmentUploadPreview,
107103
ImageUploadPreview,
108-
initialValue,
109104
Input,
110105
InputButtons,
111106
InputEditingStateHeader,
112107
InputReplyStateHeader,
113108
isCommandUIEnabled,
114109
maxNumberOfFiles,
115-
mentionAllAppUsersEnabled,
116-
mentionAllAppUsersQuery,
117110
MoreOptionsButton,
118111
openPollCreationDialog,
119112
SendButton,
@@ -124,18 +117,10 @@ export const useCreateInputMessageInputContext = ({
124117
ShowThreadMessageInChannelButton,
125118
StartAudioRecordingButton,
126119
StopMessageStreamingButton,
127-
UploadProgressIndicator,
128120
VideoAttachmentUploadPreview,
129121
}),
130122
// eslint-disable-next-line react-hooks/exhaustive-deps
131-
[
132-
compressImageQuality,
133-
channelId,
134-
editingDep,
135-
initialValue,
136-
CreatePollContent,
137-
showPollCreationDialog,
138-
],
123+
[compressImageQuality, channelId, editingDep, CreatePollContent, showPollCreationDialog],
139124
);
140125

141126
return inputMessageInputContext;

package/src/components/MessageInput/__tests__/UploadProgressIndicator.test.js renamed to package/src/components/MessageInput/__tests__/AttachmentUploadProgressIndicator.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { ProgressIndicatorTypes } from '../../../utils/utils';
77

88
import { AttachmentUploadProgressIndicator } from '../components/AttachmentPreview/AttachmentUploadProgressIndicator';
99

10-
describe('UploadProgressIndicator', () => {
11-
it('should render an inactive UploadProgressIndicator', async () => {
10+
describe('AttachmentUploadProgressIndicator', () => {
11+
it('should render an inactive AttachmentUploadProgressIndicator', async () => {
1212
const action = jest.fn();
1313

1414
render(
@@ -27,7 +27,7 @@ describe('UploadProgressIndicator', () => {
2727
});
2828
});
2929

30-
it('should render an active UploadProgressIndicator', async () => {
30+
it('should render an active AttachmentUploadProgressIndicator', async () => {
3131
const action = jest.fn();
3232

3333
render(
@@ -46,7 +46,7 @@ describe('UploadProgressIndicator', () => {
4646
});
4747
});
4848

49-
it('should render an active UploadProgressIndicator and not-supported indicator', async () => {
49+
it('should render an active AttachmentUploadProgressIndicator and not-supported indicator', async () => {
5050
const action = jest.fn();
5151

5252
render(
@@ -66,7 +66,7 @@ describe('UploadProgressIndicator', () => {
6666
});
6767
});
6868

69-
it('should render an active UploadProgressIndicator and in-progress indicator', async () => {
69+
it('should render an active AttachmentUploadProgressIndicator and in-progress indicator', async () => {
7070
const action = jest.fn();
7171

7272
render(
@@ -86,7 +86,7 @@ describe('UploadProgressIndicator', () => {
8686
});
8787
});
8888

89-
it('should render an active UploadProgressIndicator and retry indicator', async () => {
89+
it('should render an active AttachmentUploadProgressIndicator and retry indicator', async () => {
9090
const action = jest.fn();
9191
const user = userEvent.setup();
9292

package/src/components/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ export * from './MessageInput/SendButton';
133133
export * from './MessageInput/StopMessageStreamingButton';
134134
export * from './MessageInput/ShowThreadMessageInChannelButton';
135135
export * from './MessageInput/components/AttachmentPreview/AttachmentUploadProgressIndicator';
136+
export * from './MessageInput/components/AttachmentPreview/AttachmentUnsupportedIndicator';
137+
export * from './MessageInput/components/AttachmentPreview/AudioAttachmentUploadPreview';
138+
export * from './MessageInput/components/AttachmentPreview/FileAttachmentUploadPreview';
139+
export * from './MessageInput/components/AttachmentPreview/ImageAttachmentUploadPreview';
140+
export * from './MessageInput/components/AttachmentPreview/VideoAttachmentUploadPreview';
136141

137142
export * from './MessageList/DateHeader';
138143
export * from './MessageList/hooks/useMessageList';

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import {
1919
TextComposerMiddleware,
2020
UpdateMessageOptions,
2121
UploadRequestFn,
22-
UserFilters,
23-
UserOptions,
2422
UserResponse,
25-
UserSort,
2623
} from 'stream-chat';
2724

2825
import { useAttachmentManagerState } from './hooks/useAttachmentManagerState';
@@ -83,12 +80,6 @@ import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
8380

8481
import { isTestEnvironment } from '../utils/isTestEnvironment';
8582

86-
export type MentionAllAppUsersQuery = {
87-
filters?: UserFilters;
88-
options?: UserOptions;
89-
sort?: UserSort;
90-
};
91-
9283
export type LocalMessageInputContext = {
9384
closeAttachmentPicker: () => void;
9485
/** The time at which the active cooldown will end */
@@ -202,10 +193,7 @@ export type InputMessageInputContextValue = {
202193
* **default** [CooldownTimer](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageInput/CooldownTimer.tsx)
203194
*/
204195
CooldownTimer: React.ComponentType<CooldownTimerProps>;
205-
editMessage: ({
206-
localMessage,
207-
options,
208-
}: {
196+
editMessage: (params: {
209197
localMessage: LocalMessage;
210198
options?: UpdateMessageOptions;
211199
}) => ReturnType<StreamChat['updateMessage']>;
@@ -273,18 +261,14 @@ export type InputMessageInputContextValue = {
273261
StopMessageStreamingButton: React.ComponentType<StopMessageStreamingButtonProps> | null;
274262
/**
275263
* Custom UI component to render upload progress indicator on attachment preview.
276-
*
277-
* **Default** [UploadProgressIndicator](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/components/MessageInput/UploadProgressIndicator.tsx)
278264
*/
279-
UploadProgressIndicator: React.ComponentType<AttachmentUploadProgressIndicatorProps>;
265+
AttachmentUploadProgressIndicator: React.ComponentType<AttachmentUploadProgressIndicatorProps>;
280266
/**
281267
* Additional props for underlying TextInput component. These props will be forwarded as it is to TextInput component.
282268
*
283269
* @see See https://reactnative.dev/docs/textinput#reference
284270
*/
285271
additionalTextInputProps?: TextInputProps;
286-
/** Max number of suggestions to display in autocomplete list. Defaults to 10. */
287-
autoCompleteSuggestionsLimit?: number;
288272
closePollCreationDialog?: () => void;
289273
/**
290274
* Compress image with quality (from 0 to 1, where 1 is best quality).
@@ -318,8 +302,7 @@ export type InputMessageInputContextValue = {
318302
* Handler for when the attach button is pressed.
319303
*/
320304
handleAttachButtonPress?: () => void;
321-
/** Initial value to set on input */
322-
initialValue?: string;
305+
323306
/**
324307
* Custom UI component for AutoCompleteInput.
325308
* Has access to all of [MessageInputContext](https://github.com/GetStream/stream-chat-react-native/blob/main/package/src/contexts/messageInputContext/MessageInputContext.tsx)
@@ -346,9 +329,6 @@ export type InputMessageInputContextValue = {
346329
* - toggleAttachmentPicker
347330
*/
348331
InputButtons?: React.ComponentType<InputButtonsProps>;
349-
mentionAllAppUsersEnabled?: boolean;
350-
/** Object containing filters/sort/options overrides for an @mention user query */
351-
mentionAllAppUsersQuery?: MentionAllAppUsersQuery;
352332
openPollCreationDialog?: ({ sendMessage }: Pick<LocalMessageInputContext, 'sendMessage'>) => void;
353333
SendMessageDisallowedIndicator?: React.ComponentType;
354334
/**

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const useCreateMessageInputContext = ({
1010
asyncMessagesMultiSendEnabled,
1111
asyncMessagesSlideToCancelDistance,
1212
AttachButton,
13+
AttachmentUploadProgressIndicator,
1314
AudioAttachmentUploadPreview,
1415
AudioRecorder,
1516
audioRecordingEnabled,
@@ -20,7 +21,6 @@ export const useCreateMessageInputContext = ({
2021
AutoCompleteSuggestionHeader,
2122
AutoCompleteSuggestionItem,
2223
AutoCompleteSuggestionList,
23-
autoCompleteSuggestionsLimit,
2424
clearEditingState,
2525
closeAttachmentPicker,
2626
closePollCreationDialog,
@@ -42,15 +42,12 @@ export const useCreateMessageInputContext = ({
4242
hasImagePicker,
4343
ImageAttachmentUploadPreview,
4444
ImageUploadPreview,
45-
initialValue,
4645
Input,
4746
inputBoxRef,
4847
InputButtons,
4948
InputEditingStateHeader,
5049
InputReplyStateHeader,
5150
maxNumberOfFiles,
52-
mentionAllAppUsersEnabled,
53-
mentionAllAppUsersQuery,
5451
MoreOptionsButton,
5552
openAttachmentPicker,
5653
openFilePicker,
@@ -75,7 +72,6 @@ export const useCreateMessageInputContext = ({
7572
thread,
7673
toggleAttachmentPicker,
7774
uploadNewFile,
78-
UploadProgressIndicator,
7975
VideoAttachmentUploadPreview,
8076
}: MessageInputContextValue & Pick<ThreadContextValue, 'thread'>) => {
8177
const editingdep = editing?.id;
@@ -89,6 +85,7 @@ export const useCreateMessageInputContext = ({
8985
asyncMessagesMultiSendEnabled,
9086
asyncMessagesSlideToCancelDistance,
9187
AttachButton,
88+
AttachmentUploadProgressIndicator,
9289
AudioAttachmentUploadPreview,
9390
AudioRecorder,
9491
audioRecordingEnabled,
@@ -99,7 +96,6 @@ export const useCreateMessageInputContext = ({
9996
AutoCompleteSuggestionHeader,
10097
AutoCompleteSuggestionItem,
10198
AutoCompleteSuggestionList,
102-
autoCompleteSuggestionsLimit,
10399
clearEditingState,
104100
closeAttachmentPicker,
105101
closePollCreationDialog,
@@ -120,16 +116,13 @@ export const useCreateMessageInputContext = ({
120116
hasImagePicker,
121117
ImageAttachmentUploadPreview,
122118
ImageUploadPreview,
123-
initialValue,
124119
Input,
125120
inputBoxRef,
126121
InputButtons,
127122
InputEditingStateHeader,
128123
InputReplyStateHeader,
129124
isCommandUIEnabled,
130125
maxNumberOfFiles,
131-
mentionAllAppUsersEnabled,
132-
mentionAllAppUsersQuery,
133126
MoreOptionsButton,
134127
openAttachmentPicker,
135128
openFilePicker,
@@ -153,7 +146,6 @@ export const useCreateMessageInputContext = ({
153146
takeAndUploadImage,
154147
toggleAttachmentPicker,
155148
uploadNewFile,
156-
UploadProgressIndicator,
157149
VideoAttachmentUploadPreview,
158150
}),
159151
// eslint-disable-next-line react-hooks/exhaustive-deps

0 commit comments

Comments
 (0)