Skip to content

Commit f103b28

Browse files
committed
chore: resolve conflicts from base branch
2 parents 61dcb47 + 03732df commit f103b28

File tree

6 files changed

+46
-53
lines changed

6 files changed

+46
-53
lines changed

examples/TypeScriptMessaging/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ type AppContextType = {
195195

196196
const AppContext = React.createContext({} as AppContextType);
197197

198-
const NavigatorModule = () => {
198+
const StackNavigator = () => {
199199
const { channel } = useContext(AppContext);
200200

201201
return (
@@ -260,7 +260,7 @@ const App = () => {
260260
return (
261261
<OverlayProvider i18nInstance={streami18n} value={{ style: theme }}>
262262
<Chat client={chatClient} i18nInstance={streami18n} enableOfflineSupport>
263-
<NavigatorModule />
263+
<StackNavigator />
264264
</Chat>
265265
</OverlayProvider>
266266
);

package/src/components/Channel/Channel.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
622622
loadingMoreRecent: loadingMoreRecentProp,
623623
markdownRules,
624624
markReadOnMount = true,
625-
maxNumberOfFiles = 10,
626625
maxTimeBetweenGroupedMessages,
627626
Message = MessageDefault,
628627
MessageActionList = MessageActionListDefault,
@@ -1781,7 +1780,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
17811780
InputEditingStateHeader,
17821781
InputReplyStateHeader,
17831782
isCommandUIEnabled,
1784-
maxNumberOfFiles,
17851783
MoreOptionsButton,
17861784
openPollCreationDialog,
17871785
SendButton,

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ export const useCreateInputMessageInputContext = ({
5151
InputEditingStateHeader,
5252
InputReplyStateHeader,
5353
isCommandUIEnabled,
54-
maxNumberOfFiles,
5554
MoreOptionsButton,
5655
openPollCreationDialog,
5756
SendButton,
@@ -119,7 +118,6 @@ export const useCreateInputMessageInputContext = ({
119118
InputEditingStateHeader,
120119
InputReplyStateHeader,
121120
isCommandUIEnabled,
122-
maxNumberOfFiles,
123121
MoreOptionsButton,
124122
openPollCreationDialog,
125123
SendButton,

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ type MessageInputPropsWithContext = Partial<
144144
| 'CooldownTimer'
145145
| 'closeAttachmentPicker'
146146
| 'compressImageQuality'
147-
| 'doFileUploadRequest'
148147
| 'FileUploadPreview'
149148
| 'ImageUploadPreview'
150149
| 'Input'
@@ -158,7 +157,6 @@ type MessageInputPropsWithContext = Partial<
158157
| 'VideoRecorderSelectorIcon'
159158
| 'CommandInput'
160159
| 'InputReplyStateHeader'
161-
| 'maxNumberOfFiles'
162160
| 'SendButton'
163161
| 'ShowThreadMessageInChannelButton'
164162
| 'StartAudioRecordingButton'
@@ -211,7 +209,6 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
211209
cooldownEndsAt,
212210
CooldownTimer,
213211
CreatePollContent,
214-
doFileUploadRequest,
215212
editing,
216213
FileUploadPreview,
217214
ImageUploadPreview,
@@ -222,7 +219,6 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
222219
CommandInput,
223220
InputReplyStateHeader,
224221
isOnline,
225-
maxNumberOfFiles,
226222
members,
227223
Reply,
228224
SendButton,
@@ -236,7 +232,7 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
236232
} = props;
237233

238234
const messageComposer = useMessageComposer();
239-
const { attachmentManager, textComposer } = messageComposer;
235+
const { textComposer } = messageComposer;
240236
const { command, hasText } = useStateStore(textComposer.state, textComposerStateSelector);
241237
const { quotedMessage } = useStateStore(messageComposer.state, messageComposerStateStoreSelector);
242238
const { attachments } = useAttachmentManagerState();
@@ -269,15 +265,13 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
269265

270266
const { seconds: cooldownRemainingSeconds } = useCountdown(cooldownEndsAt);
271267

272-
useEffect(() => {
273-
attachmentManager.maxNumberOfFilesPerMessage = maxNumberOfFiles;
274-
if (doFileUploadRequest) {
275-
attachmentManager.setCustomUploadFn(doFileUploadRequest);
276-
}
277-
278-
return closeAttachmentPicker;
279-
// eslint-disable-next-line react-hooks/exhaustive-deps
280-
}, []);
268+
// Close the attachment picker state when the component unmounts
269+
useEffect(
270+
() => () => {
271+
closeAttachmentPicker();
272+
},
273+
[closeAttachmentPicker],
274+
);
281275

282276
useEffect(() => {
283277
const { editedMessage } = messageComposer;
@@ -817,7 +811,6 @@ export const MessageInput = (props: MessageInputProps) => {
817811
CooldownTimer,
818812
CreatePollContent,
819813
CreatePollIcon,
820-
doFileUploadRequest,
821814
FileSelectorIcon,
822815
FileUploadPreview,
823816
ImageSelectorIcon,
@@ -828,7 +821,6 @@ export const MessageInput = (props: MessageInputProps) => {
828821
InputEditingStateHeader,
829822
CommandInput,
830823
InputReplyStateHeader,
831-
maxNumberOfFiles,
832824
openPollCreationDialog,
833825
SendButton,
834826
sendMessage,
@@ -891,7 +883,6 @@ export const MessageInput = (props: MessageInputProps) => {
891883
CooldownTimer,
892884
CreatePollContent,
893885
CreatePollIcon,
894-
doFileUploadRequest,
895886
editing,
896887
FileSelectorIcon,
897888
FileUploadPreview,
@@ -903,7 +894,6 @@ export const MessageInput = (props: MessageInputProps) => {
903894
InputEditingStateHeader,
904895
InputReplyStateHeader,
905896
isOnline,
906-
maxNumberOfFiles,
907897
members,
908898
openPollCreationDialog,
909899
Reply,

package/src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { Alert, Keyboard, Linking, TextInput, TextInputProps } from 'react-nativ
1111

1212
import { BottomSheetHandleProps } from '@gorhom/bottom-sheet';
1313
import {
14-
createApplyCommandSettingsMiddleware,
1514
createCommandInjectionMiddleware,
15+
createCommandStringExtractionMiddleware,
1616
createDraftCommandInjectionMiddleware,
1717
LocalMessage,
1818
Message,
@@ -292,8 +292,6 @@ export type InputMessageInputContextValue = {
292292
isCommandUIEnabled?: boolean;
293293
CommandInput: React.ComponentType<CommandInputProps>;
294294
InputReplyStateHeader: React.ComponentType;
295-
/** Limit on allowed number of files to attach at a time. */
296-
maxNumberOfFiles: number;
297295
/**
298296
* Custom UI component for more options button.
299297
*
@@ -452,33 +450,44 @@ export const MessageInputProvider = ({
452450
setSendThreadMessageInChannel(false);
453451
}, [threadId]);
454452

453+
/**
454+
* These are the RN SDK specific middlewares that are added to the message composer to provide the default behaviour.
455+
* TODO: Discuss and decide if we provide them by default in the SDK or leave it to the user to add them if they want the feature.
456+
*/
455457
useEffect(() => {
456-
if (!client) {
457-
return;
458+
if (value.doFileUploadRequest) {
459+
attachmentManager.setCustomUploadFn(value.doFileUploadRequest);
458460
}
459461

460-
client.setMessageComposerSetupFunction(({ composer }) => {
461-
isCommandUIEnabled &&
462-
composer.compositionMiddlewareExecutor.insert({
463-
middleware: [createCommandInjectionMiddleware(composer)],
464-
position: { after: 'stream-io/message-composer-middleware/attachments' },
465-
});
466-
enableOfflineSupport &&
467-
composer.compositionMiddlewareExecutor.replace([
468-
createAttachmentsCompositionMiddleware(composer),
469-
]);
470-
isCommandUIEnabled &&
471-
composer.draftCompositionMiddlewareExecutor.insert({
472-
middleware: [createDraftCommandInjectionMiddleware(composer)],
473-
position: { after: 'stream-io/message-composer-middleware/draft-attachments' },
474-
});
475-
isCommandUIEnabled &&
476-
composer.textComposer.middlewareExecutor.insert({
477-
middleware: [createApplyCommandSettingsMiddleware() as TextComposerMiddleware],
478-
position: { after: 'stream-io/text-composer/commands-middleware' },
479-
});
480-
});
481-
}, [client, isCommandUIEnabled, enableOfflineSupport]);
462+
if (isCommandUIEnabled) {
463+
messageComposer.compositionMiddlewareExecutor.insert({
464+
middleware: [createCommandInjectionMiddleware(messageComposer)],
465+
position: { after: 'stream-io/message-composer-middleware/attachments' },
466+
});
467+
468+
messageComposer.draftCompositionMiddlewareExecutor.insert({
469+
middleware: [createDraftCommandInjectionMiddleware(messageComposer)],
470+
position: { after: 'stream-io/message-composer-middleware/draft-attachments' },
471+
});
472+
473+
messageComposer.textComposer.middlewareExecutor.insert({
474+
middleware: [createCommandStringExtractionMiddleware() as TextComposerMiddleware],
475+
position: { after: 'stream-io/text-composer/commands-middleware' },
476+
});
477+
}
478+
479+
if (enableOfflineSupport) {
480+
messageComposer.compositionMiddlewareExecutor.replace([
481+
createAttachmentsCompositionMiddleware(messageComposer),
482+
]);
483+
}
484+
}, [
485+
value.doFileUploadRequest,
486+
isCommandUIEnabled,
487+
enableOfflineSupport,
488+
messageComposer,
489+
attachmentManager,
490+
]);
482491

483492
/**
484493
* Function for capturing a photo and uploading it

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const useCreateMessageInputContext = ({
5454
InputButtons,
5555
InputEditingStateHeader,
5656
InputReplyStateHeader,
57-
maxNumberOfFiles,
5857
MoreOptionsButton,
5958
openAttachmentPicker,
6059
openFilePicker,
@@ -134,7 +133,6 @@ export const useCreateMessageInputContext = ({
134133
InputEditingStateHeader,
135134
InputReplyStateHeader,
136135
isCommandUIEnabled,
137-
maxNumberOfFiles,
138136
MoreOptionsButton,
139137
openAttachmentPicker,
140138
openFilePicker,

0 commit comments

Comments
 (0)