stream-chat-react-native-core 5.34.0 → 5.34.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/lib/commonjs/components/Channel/Channel.js +0 -1
  2. package/lib/commonjs/components/Channel/Channel.js.map +1 -1
  3. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js +1 -3
  4. package/lib/commonjs/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  5. package/lib/commonjs/components/Message/Message.js +1 -9
  6. package/lib/commonjs/components/Message/Message.js.map +1 -1
  7. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js +3 -10
  8. package/lib/commonjs/components/Message/MessageSimple/MessageContent.js.map +1 -1
  9. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +0 -6
  10. package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  11. package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js +1 -3
  12. package/lib/commonjs/components/Message/hooks/useCreateMessageContext.js.map +1 -1
  13. package/lib/commonjs/components/MessageInput/AttachButton.js +4 -17
  14. package/lib/commonjs/components/MessageInput/AttachButton.js.map +1 -1
  15. package/lib/commonjs/components/MessageInput/CommandsButton.js +3 -14
  16. package/lib/commonjs/components/MessageInput/CommandsButton.js.map +1 -1
  17. package/lib/commonjs/components/MessageInput/MessageInput.js +5 -14
  18. package/lib/commonjs/components/MessageInput/MessageInput.js.map +1 -1
  19. package/lib/commonjs/components/MessageInput/MoreOptionsButton.js +2 -25
  20. package/lib/commonjs/components/MessageInput/MoreOptionsButton.js.map +1 -1
  21. package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js +3 -16
  22. package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
  23. package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +1 -12
  24. package/lib/commonjs/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
  25. package/lib/commonjs/components/MessageInput/components/InputEditingStateHeader.js +15 -26
  26. package/lib/commonjs/components/MessageInput/components/InputEditingStateHeader.js.map +1 -1
  27. package/lib/commonjs/components/MessageInput/components/InputGiphySearch.js +15 -28
  28. package/lib/commonjs/components/MessageInput/components/InputGiphySearch.js.map +1 -1
  29. package/lib/commonjs/components/MessageInput/components/InputReplyStateHeader.js +15 -26
  30. package/lib/commonjs/components/MessageInput/components/InputReplyStateHeader.js.map +1 -1
  31. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +1 -3
  32. package/lib/commonjs/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  33. package/lib/commonjs/utils/utils.js +2 -1
  34. package/lib/commonjs/utils/utils.js.map +1 -1
  35. package/lib/commonjs/version.json +1 -1
  36. package/lib/module/components/Channel/Channel.js +0 -1
  37. package/lib/module/components/Channel/Channel.js.map +1 -1
  38. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js +1 -3
  39. package/lib/module/components/Channel/hooks/useCreateInputMessageInputContext.js.map +1 -1
  40. package/lib/module/components/Message/Message.js +1 -9
  41. package/lib/module/components/Message/Message.js.map +1 -1
  42. package/lib/module/components/Message/MessageSimple/MessageContent.js +3 -10
  43. package/lib/module/components/Message/MessageSimple/MessageContent.js.map +1 -1
  44. package/lib/module/components/Message/MessageSimple/MessageSimple.js +0 -6
  45. package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
  46. package/lib/module/components/Message/hooks/useCreateMessageContext.js +1 -3
  47. package/lib/module/components/Message/hooks/useCreateMessageContext.js.map +1 -1
  48. package/lib/module/components/MessageInput/AttachButton.js +4 -17
  49. package/lib/module/components/MessageInput/AttachButton.js.map +1 -1
  50. package/lib/module/components/MessageInput/CommandsButton.js +3 -14
  51. package/lib/module/components/MessageInput/CommandsButton.js.map +1 -1
  52. package/lib/module/components/MessageInput/MessageInput.js +5 -14
  53. package/lib/module/components/MessageInput/MessageInput.js.map +1 -1
  54. package/lib/module/components/MessageInput/MoreOptionsButton.js +2 -25
  55. package/lib/module/components/MessageInput/MoreOptionsButton.js.map +1 -1
  56. package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js +3 -16
  57. package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecorder.js.map +1 -1
  58. package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js +1 -12
  59. package/lib/module/components/MessageInput/components/AudioRecorder/AudioRecordingButton.js.map +1 -1
  60. package/lib/module/components/MessageInput/components/InputEditingStateHeader.js +15 -26
  61. package/lib/module/components/MessageInput/components/InputEditingStateHeader.js.map +1 -1
  62. package/lib/module/components/MessageInput/components/InputGiphySearch.js +15 -28
  63. package/lib/module/components/MessageInput/components/InputGiphySearch.js.map +1 -1
  64. package/lib/module/components/MessageInput/components/InputReplyStateHeader.js +15 -26
  65. package/lib/module/components/MessageInput/components/InputReplyStateHeader.js.map +1 -1
  66. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js +1 -3
  67. package/lib/module/contexts/messageInputContext/hooks/useCreateMessageInputContext.js.map +1 -1
  68. package/lib/module/utils/utils.js +2 -1
  69. package/lib/module/utils/utils.js.map +1 -1
  70. package/lib/module/version.json +1 -1
  71. package/lib/typescript/components/Channel/Channel.d.ts.map +1 -1
  72. package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts +1 -74
  73. package/lib/typescript/components/Channel/hooks/useCreateInputMessageInputContext.d.ts.map +1 -1
  74. package/lib/typescript/components/Message/Message.d.ts +1 -1
  75. package/lib/typescript/components/Message/Message.d.ts.map +1 -1
  76. package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts +1 -1
  77. package/lib/typescript/components/Message/MessageSimple/MessageContent.d.ts.map +1 -1
  78. package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts +1 -1
  79. package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts.map +1 -1
  80. package/lib/typescript/components/Message/hooks/useCreateMessageContext.d.ts +1 -1
  81. package/lib/typescript/components/Message/hooks/useCreateMessageContext.d.ts.map +1 -1
  82. package/lib/typescript/components/MessageInput/AttachButton.d.ts +3 -5
  83. package/lib/typescript/components/MessageInput/AttachButton.d.ts.map +1 -1
  84. package/lib/typescript/components/MessageInput/CommandsButton.d.ts +1 -2
  85. package/lib/typescript/components/MessageInput/CommandsButton.d.ts.map +1 -1
  86. package/lib/typescript/components/MessageInput/MessageInput.d.ts +1 -1
  87. package/lib/typescript/components/MessageInput/MessageInput.d.ts.map +1 -1
  88. package/lib/typescript/components/MessageInput/MoreOptionsButton.d.ts +2 -9
  89. package/lib/typescript/components/MessageInput/MoreOptionsButton.d.ts.map +1 -1
  90. package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecorder.d.ts +1 -2
  91. package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecorder.d.ts.map +1 -1
  92. package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecordingButton.d.ts +1 -2
  93. package/lib/typescript/components/MessageInput/components/AudioRecorder/AudioRecordingButton.d.ts.map +1 -1
  94. package/lib/typescript/components/MessageInput/components/InputEditingStateHeader.d.ts +2 -5
  95. package/lib/typescript/components/MessageInput/components/InputEditingStateHeader.d.ts.map +1 -1
  96. package/lib/typescript/components/MessageInput/components/InputGiphySearch.d.ts +4 -5
  97. package/lib/typescript/components/MessageInput/components/InputGiphySearch.d.ts.map +1 -1
  98. package/lib/typescript/components/MessageInput/components/InputReplyStateHeader.d.ts +2 -5
  99. package/lib/typescript/components/MessageInput/components/InputReplyStateHeader.d.ts.map +1 -1
  100. package/lib/typescript/contexts/messageContext/MessageContext.d.ts +2 -2
  101. package/lib/typescript/contexts/messageContext/MessageContext.d.ts.map +1 -1
  102. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts +4 -4
  103. package/lib/typescript/contexts/messageInputContext/MessageInputContext.d.ts.map +1 -1
  104. package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts +1 -1
  105. package/lib/typescript/contexts/messageInputContext/hooks/useCreateMessageInputContext.d.ts.map +1 -1
  106. package/lib/typescript/utils/utils.d.ts +1 -1
  107. package/lib/typescript/utils/utils.d.ts.map +1 -1
  108. package/package.json +1 -1
  109. package/src/components/Channel/Channel.tsx +0 -1
  110. package/src/components/Channel/__tests__/ownCapabilities.test.js +0 -18
  111. package/src/components/Channel/hooks/useCreateInputMessageInputContext.ts +1 -11
  112. package/src/components/Message/Message.tsx +3 -15
  113. package/src/components/Message/MessageSimple/MessageContent.tsx +1 -10
  114. package/src/components/Message/MessageSimple/MessageSimple.tsx +2 -14
  115. package/src/components/Message/hooks/useCreateMessageContext.ts +0 -3
  116. package/src/components/MessageInput/AttachButton.tsx +12 -47
  117. package/src/components/MessageInput/CommandsButton.tsx +9 -23
  118. package/src/components/MessageInput/MessageInput.tsx +10 -22
  119. package/src/components/MessageInput/MoreOptionsButton.tsx +3 -53
  120. package/src/components/MessageInput/__tests__/__snapshots__/AttachButton.test.js.snap +2 -2
  121. package/src/components/MessageInput/components/AudioRecorder/AudioRecorder.tsx +36 -52
  122. package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx +27 -42
  123. package/src/components/MessageInput/components/InputEditingStateHeader.tsx +18 -44
  124. package/src/components/MessageInput/components/InputGiphySearch.tsx +27 -51
  125. package/src/components/MessageInput/components/InputReplyStateHeader.tsx +19 -44
  126. package/src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap +2 -2
  127. package/src/contexts/messageContext/MessageContext.tsx +1 -1
  128. package/src/contexts/messageInputContext/MessageInputContext.tsx +3 -3
  129. package/src/contexts/messageInputContext/hooks/useCreateMessageInputContext.ts +0 -3
  130. package/src/utils/utils.ts +2 -1
  131. package/src/version.json +1 -1
@@ -2,10 +2,6 @@ import React from 'react';
2
2
  import type { GestureResponderEvent } from 'react-native';
3
3
  import { Pressable } from 'react-native';
4
4
 
5
- import {
6
- ChannelContextValue,
7
- useChannelContext,
8
- } from '../../contexts/channelContext/ChannelContext';
9
5
  import {
10
6
  isSuggestionCommand,
11
7
  SuggestionsContextValue,
@@ -18,18 +14,17 @@ import type { DefaultStreamChatGenerics } from '../../types/types';
18
14
 
19
15
  type CommandsButtonPropsWithContext<
20
16
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
21
- > = Pick<ChannelContextValue<StreamChatGenerics>, 'disabled'> &
22
- Pick<SuggestionsContextValue<StreamChatGenerics>, 'suggestions'> & {
23
- /** Function that opens commands selector */
24
- handleOnPress?: ((event: GestureResponderEvent) => void) & (() => void);
25
- };
17
+ > = Pick<SuggestionsContextValue<StreamChatGenerics>, 'suggestions'> & {
18
+ /** Function that opens commands selector */
19
+ handleOnPress?: ((event: GestureResponderEvent) => void) & (() => void);
20
+ };
26
21
 
27
22
  const CommandsButtonWithContext = <
28
23
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
29
24
  >(
30
25
  props: CommandsButtonPropsWithContext<StreamChatGenerics>,
31
26
  ) => {
32
- const { disabled, handleOnPress, suggestions } = props;
27
+ const { handleOnPress, suggestions } = props;
33
28
 
34
29
  const {
35
30
  theme: {
@@ -39,12 +34,7 @@ const CommandsButtonWithContext = <
39
34
  } = useTheme();
40
35
 
41
36
  return (
42
- <Pressable
43
- disabled={disabled}
44
- onPress={handleOnPress}
45
- style={[commandsButton]}
46
- testID='commands-button'
47
- >
37
+ <Pressable onPress={handleOnPress} style={[commandsButton]} testID='commands-button'>
48
38
  <Lightning
49
39
  pathFill={
50
40
  suggestions && suggestions.data.some((suggestion) => isSuggestionCommand(suggestion))
@@ -60,11 +50,8 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
60
50
  prevProps: CommandsButtonPropsWithContext<StreamChatGenerics>,
61
51
  nextProps: CommandsButtonPropsWithContext<StreamChatGenerics>,
62
52
  ) => {
63
- const { disabled: prevDisabled, suggestions: prevSuggestions } = prevProps;
64
- const { disabled: nextDisabled, suggestions: nextSuggestions } = nextProps;
65
-
66
- const disabledEqual = prevDisabled === nextDisabled;
67
- if (!disabledEqual) return false;
53
+ const { suggestions: prevSuggestions } = prevProps;
54
+ const { suggestions: nextSuggestions } = nextProps;
68
55
 
69
56
  const suggestionsEqual = !!prevSuggestions === !!nextSuggestions;
70
57
  if (!suggestionsEqual) return false;
@@ -89,10 +76,9 @@ export const CommandsButton = <
89
76
  >(
90
77
  props: CommandsButtonProps<StreamChatGenerics>,
91
78
  ) => {
92
- const { disabled = false } = useChannelContext<StreamChatGenerics>();
93
79
  const { suggestions } = useSuggestionsContext<StreamChatGenerics>();
94
80
 
95
- return <MemoizedCommandsButton {...{ disabled, suggestions }} {...props} />;
81
+ return <MemoizedCommandsButton {...{ suggestions }} {...props} />;
96
82
  };
97
83
 
98
84
  CommandsButton.displayName = 'CommandsButton{messageInput}';
@@ -21,7 +21,7 @@ import type { UserResponse } from 'stream-chat';
21
21
  import { useAudioController } from './hooks/useAudioController';
22
22
  import { useCountdown } from './hooks/useCountdown';
23
23
 
24
- import { ChatContextValue, useChatContext } from '../../contexts';
24
+ import { ChatContextValue, useChatContext, useOwnCapabilitiesContext } from '../../contexts';
25
25
  import {
26
26
  AttachmentPickerContextValue,
27
27
  useAttachmentPickerContext,
@@ -38,7 +38,6 @@ import {
38
38
  MessagesContextValue,
39
39
  useMessagesContext,
40
40
  } from '../../contexts/messagesContext/MessagesContext';
41
- import { useOwnCapabilitiesContext } from '../../contexts/ownCapabilitiesContext/OwnCapabilitiesContext';
42
41
  import {
43
42
  SuggestionsContextValue,
44
43
  useSuggestionsContext,
@@ -96,10 +95,7 @@ type MessageInputPropsWithContext<
96
95
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
97
96
  > = Pick<AttachmentPickerContextValue, 'AttachmentPickerSelectionBar'> &
98
97
  Pick<ChatContextValue<StreamChatGenerics>, 'isOnline'> &
99
- Pick<
100
- ChannelContextValue<StreamChatGenerics>,
101
- 'disabled' | 'members' | 'threadList' | 'watchers'
102
- > &
98
+ Pick<ChannelContextValue<StreamChatGenerics>, 'members' | 'threadList' | 'watchers'> &
103
99
  Pick<
104
100
  MessageInputContextValue<StreamChatGenerics>,
105
101
  | 'additionalTextInputProps'
@@ -184,7 +180,6 @@ const MessageInputWithContext = <
184
180
  closeAttachmentPicker,
185
181
  cooldownEndsAt,
186
182
  CooldownTimer,
187
- disabled,
188
183
  editing,
189
184
  FileUploadPreview,
190
185
  fileUploads,
@@ -457,7 +452,8 @@ const MessageInputWithContext = <
457
452
  fileUploads.length > 0 ||
458
453
  mentionedUsers.length > 0 ||
459
454
  imageUploads.length > 0 ||
460
- numberOfUploads > 0)
455
+ numberOfUploads > 0) &&
456
+ resetInput
461
457
  ) {
462
458
  resetInput();
463
459
  }
@@ -517,7 +513,6 @@ const MessageInputWithContext = <
517
513
  };
518
514
 
519
515
  const additionalTextInputContainerProps = {
520
- editable: disabled ? false : undefined,
521
516
  ...additionalTextInputProps,
522
517
  };
523
518
 
@@ -771,12 +766,7 @@ const MessageInputWithContext = <
771
766
  ) : (
772
767
  <View style={[styles.sendButtonContainer, sendButtonContainer]}>
773
768
  <SendButton
774
- disabled={
775
- disabled ||
776
- sending.current ||
777
- !isValidMessage() ||
778
- (giphyActive && !isOnline)
779
- }
769
+ disabled={sending.current || !isValidMessage() || (giphyActive && !isOnline)}
780
770
  />
781
771
  </View>
782
772
  ))}
@@ -849,7 +839,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
849
839
  asyncMessagesSlideToCancelDistance: prevAsyncMessagesSlideToCancelDistance,
850
840
  asyncUploads: prevAsyncUploads,
851
841
  audioRecordingEnabled: prevAsyncMessagesEnabled,
852
- disabled: prevDisabled,
853
842
  editing: prevEditing,
854
843
  fileUploads: prevFileUploads,
855
844
  giphyActive: prevGiphyActive,
@@ -872,7 +861,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
872
861
  asyncMessagesSlideToCancelDistance: nextAsyncMessagesSlideToCancelDistance,
873
862
  asyncUploads: nextAsyncUploads,
874
863
  audioRecordingEnabled: nextAsyncMessagesEnabled,
875
- disabled: nextDisabled,
876
864
  editing: nextEditing,
877
865
  fileUploads: nextFileUploads,
878
866
  giphyActive: nextGiphyActive,
@@ -911,9 +899,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
911
899
  prevAsyncMessagesSlideToCancelDistance === nextAsyncMessagesSlideToCancelDistance;
912
900
  if (!asyncMessagesSlideToCancelDistanceEqual) return false;
913
901
 
914
- const disabledEqual = prevDisabled === nextDisabled;
915
- if (!disabledEqual) return false;
916
-
917
902
  const editingEqual = !!prevEditing === !!nextEditing;
918
903
  if (!editingEqual) return false;
919
904
 
@@ -1071,7 +1056,11 @@ export const MessageInput = <
1071
1056
 
1072
1057
  const { t } = useTranslationContext();
1073
1058
 
1074
- if ((disabled || !ownCapabilities.sendMessage) && SendMessageDisallowedIndicator) {
1059
+ /**
1060
+ * Disable the message input if the channel is frozen, or the user doesn't have the capability to send a message.
1061
+ * Enable it in frozen mode, if it the input has editing state.
1062
+ */
1063
+ if (!editing && disabled && !ownCapabilities.sendMessage && SendMessageDisallowedIndicator) {
1075
1064
  return <SendMessageDisallowedIndicator />;
1076
1065
  }
1077
1066
 
@@ -1099,7 +1088,6 @@ export const MessageInput = <
1099
1088
  closeAttachmentPicker,
1100
1089
  cooldownEndsAt,
1101
1090
  CooldownTimer,
1102
- disabled,
1103
1091
  editing,
1104
1092
  FileUploadPreview,
1105
1093
  fileUploads,
@@ -2,28 +2,16 @@ import React from 'react';
2
2
  import type { GestureResponderEvent } from 'react-native';
3
3
  import { TouchableOpacity } from 'react-native-gesture-handler';
4
4
 
5
- import {
6
- ChannelContextValue,
7
- useChannelContext,
8
- } from '../../contexts/channelContext/ChannelContext';
9
5
  import { useTheme } from '../../contexts/themeContext/ThemeContext';
10
6
  import { CircleRight } from '../../icons/CircleRight';
11
7
 
12
- import type { DefaultStreamChatGenerics } from '../../types/types';
13
-
14
- type MoreOptionsButtonPropsWithContext<
15
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
16
- > = Pick<ChannelContextValue<StreamChatGenerics>, 'disabled'> & {
8
+ export type MoreOptionsButtonProps = {
17
9
  /** Function that opens attachment options bottom sheet */
18
10
  handleOnPress?: ((event: GestureResponderEvent) => void) & (() => void);
19
11
  };
20
12
 
21
- const MoreOptionsButtonWithContext = <
22
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
23
- >(
24
- props: MoreOptionsButtonPropsWithContext<StreamChatGenerics>,
25
- ) => {
26
- const { disabled, handleOnPress } = props;
13
+ export const MoreOptionsButton = (props: MoreOptionsButtonProps) => {
14
+ const { handleOnPress } = props;
27
15
 
28
16
  const {
29
17
  theme: {
@@ -34,7 +22,6 @@ const MoreOptionsButtonWithContext = <
34
22
 
35
23
  return (
36
24
  <TouchableOpacity
37
- disabled={disabled}
38
25
  hitSlop={{ bottom: 15, left: 15, right: 15, top: 15 }}
39
26
  onPress={handleOnPress}
40
27
  style={[moreOptionsButton]}
@@ -45,41 +32,4 @@ const MoreOptionsButtonWithContext = <
45
32
  );
46
33
  };
47
34
 
48
- const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
49
- prevProps: MoreOptionsButtonPropsWithContext<StreamChatGenerics>,
50
- nextProps: MoreOptionsButtonPropsWithContext<StreamChatGenerics>,
51
- ) => {
52
- const { disabled: prevDisabled, handleOnPress: prevHandleOnPress } = prevProps;
53
- const { disabled: nextDisabled, handleOnPress: nextHandleOnPress } = nextProps;
54
- const disabledEqual = prevDisabled === nextDisabled;
55
- if (!disabledEqual) return false;
56
-
57
- const handleOnPressEqual = prevHandleOnPress === nextHandleOnPress;
58
- if (!handleOnPressEqual) return false;
59
-
60
- return true;
61
- };
62
-
63
- const MemoizedMoreOptionsButton = React.memo(
64
- MoreOptionsButtonWithContext,
65
- areEqual,
66
- ) as typeof MoreOptionsButtonWithContext;
67
-
68
- export type MoreOptionsButtonProps<
69
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
70
- > = Partial<MoreOptionsButtonPropsWithContext<StreamChatGenerics>>;
71
-
72
- /**
73
- * UI Component for more options button in MessageInput component.
74
- */
75
- export const MoreOptionsButton = <
76
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
77
- >(
78
- props: MoreOptionsButtonProps<StreamChatGenerics>,
79
- ) => {
80
- const { disabled = false } = useChannelContext<StreamChatGenerics>();
81
-
82
- return <MemoizedMoreOptionsButton {...{ disabled }} {...props} />;
83
- };
84
-
85
35
  MoreOptionsButton.displayName = 'MoreOptionsButton{messageInput}';
@@ -6,7 +6,7 @@ exports[`AttachButton should render a disabled AttachButton 1`] = `
6
6
  {
7
7
  "busy": undefined,
8
8
  "checked": undefined,
9
- "disabled": true,
9
+ "disabled": undefined,
10
10
  "expanded": undefined,
11
11
  "selected": undefined,
12
12
  }
@@ -101,7 +101,7 @@ exports[`AttachButton should render an enabled AttachButton 1`] = `
101
101
  {
102
102
  "busy": undefined,
103
103
  "checked": undefined,
104
- "disabled": false,
104
+ "disabled": undefined,
105
105
  "expanded": undefined,
106
106
  "selected": undefined,
107
107
  }
@@ -5,10 +5,6 @@ import Animated from 'react-native-reanimated';
5
5
 
6
6
  import dayjs from 'dayjs';
7
7
 
8
- import {
9
- ChannelContextValue,
10
- useChannelContext,
11
- } from '../../../../contexts/channelContext/ChannelContext';
12
8
  import {
13
9
  MessageInputContextValue,
14
10
  useMessageInputContext,
@@ -21,42 +17,41 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
21
17
 
22
18
  type AudioRecorderPropsWithContext<
23
19
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
24
- > = Pick<ChannelContextValue<StreamChatGenerics>, 'disabled'> &
25
- Pick<MessageInputContextValue<StreamChatGenerics>, 'asyncMessagesMultiSendEnabled'> & {
26
- /**
27
- * Function to stop and delete the voice recording.
28
- */
29
- deleteVoiceRecording: () => Promise<void>;
30
- /**
31
- * Boolean used to show if the voice recording state is locked. This makes sure the mic button shouldn't be pressed any longer.
32
- * When the mic is locked the `AudioRecordingInProgress` component shows up.
33
- */
34
- micLocked: boolean;
35
- /**
36
- * The current voice recording that is in progress.
37
- */
38
- recording: AudioRecordingReturnType;
39
- /**
40
- * Boolean to determine if the recording has been stopped.
41
- */
42
- recordingStopped: boolean;
43
- /**
44
- * Function to stop the ongoing voice recording.
45
- */
46
- stopVoiceRecording: () => Promise<void>;
47
- /**
48
- * Function to upload the voice recording.
49
- */
50
- uploadVoiceRecording: (multiSendEnabled: boolean) => Promise<void>;
51
- /**
52
- * The duration of the voice recording.
53
- */
54
- recordingDuration?: number;
55
- /**
56
- * Style used in slide to cancel container.
57
- */
58
- slideToCancelStyle?: StyleProp<ViewStyle>;
59
- };
20
+ > = Pick<MessageInputContextValue<StreamChatGenerics>, 'asyncMessagesMultiSendEnabled'> & {
21
+ /**
22
+ * Function to stop and delete the voice recording.
23
+ */
24
+ deleteVoiceRecording: () => Promise<void>;
25
+ /**
26
+ * Boolean used to show if the voice recording state is locked. This makes sure the mic button shouldn't be pressed any longer.
27
+ * When the mic is locked the `AudioRecordingInProgress` component shows up.
28
+ */
29
+ micLocked: boolean;
30
+ /**
31
+ * The current voice recording that is in progress.
32
+ */
33
+ recording: AudioRecordingReturnType;
34
+ /**
35
+ * Boolean to determine if the recording has been stopped.
36
+ */
37
+ recordingStopped: boolean;
38
+ /**
39
+ * Function to stop the ongoing voice recording.
40
+ */
41
+ stopVoiceRecording: () => Promise<void>;
42
+ /**
43
+ * Function to upload the voice recording.
44
+ */
45
+ uploadVoiceRecording: (multiSendEnabled: boolean) => Promise<void>;
46
+ /**
47
+ * The duration of the voice recording.
48
+ */
49
+ recordingDuration?: number;
50
+ /**
51
+ * Style used in slide to cancel container.
52
+ */
53
+ slideToCancelStyle?: StyleProp<ViewStyle>;
54
+ };
60
55
 
61
56
  const StopRecording = ({
62
57
  stopVoiceRecordingHandler,
@@ -110,10 +105,8 @@ const UploadRecording = ({
110
105
 
111
106
  const DeleteRecording = ({
112
107
  deleteVoiceRecordingHandler,
113
- disabled,
114
108
  }: {
115
109
  deleteVoiceRecordingHandler: () => Promise<void>;
116
- disabled?: boolean;
117
110
  }) => {
118
111
  const {
119
112
  theme: {
@@ -125,7 +118,6 @@ const DeleteRecording = ({
125
118
  } = useTheme();
126
119
  return (
127
120
  <Pressable
128
- disabled={disabled}
129
121
  onPress={deleteVoiceRecordingHandler}
130
122
  style={[styles.deleteContainer, deleteContainer]}
131
123
  testID='delete-button'
@@ -143,7 +135,6 @@ const AudioRecorderWithContext = <
143
135
  const {
144
136
  asyncMessagesMultiSendEnabled,
145
137
  deleteVoiceRecording,
146
- disabled,
147
138
  micLocked,
148
139
  recordingDuration,
149
140
  recordingStopped,
@@ -165,7 +156,7 @@ const AudioRecorderWithContext = <
165
156
  if (recordingStopped) {
166
157
  return (
167
158
  <>
168
- <DeleteRecording deleteVoiceRecordingHandler={deleteVoiceRecording} disabled={disabled} />
159
+ <DeleteRecording deleteVoiceRecordingHandler={deleteVoiceRecording} />
169
160
  <UploadRecording
170
161
  asyncMessagesMultiSendEnabled={asyncMessagesMultiSendEnabled}
171
162
  uploadVoiceRecordingHandler={uploadVoiceRecording}
@@ -212,7 +203,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
212
203
  ) => {
213
204
  const {
214
205
  asyncMessagesMultiSendEnabled: prevAsyncMessagesMultiSendEnabled,
215
- disabled: prevDisabled,
216
206
  micLocked: prevMicLocked,
217
207
  recording: prevRecording,
218
208
  recordingDuration: prevRecordingDuration,
@@ -220,7 +210,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
220
210
  } = prevProps;
221
211
  const {
222
212
  asyncMessagesMultiSendEnabled: nextAsyncMessagesMultiSendEnabled,
223
- disabled: nextDisabled,
224
213
  micLocked: nextMicLocked,
225
214
  recording: nextRecording,
226
215
  recordingDuration: nextRecordingDuration,
@@ -231,9 +220,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
231
220
  prevAsyncMessagesMultiSendEnabled === nextAsyncMessagesMultiSendEnabled;
232
221
  if (!asyncMessagesMultiSendEnabledEqual) return false;
233
222
 
234
- const disabledEqual = prevDisabled === nextDisabled;
235
- if (!disabledEqual) return false;
236
-
237
223
  const micLockedEqual = prevMicLocked === nextMicLocked;
238
224
  if (!micLockedEqual) return false;
239
225
 
@@ -275,14 +261,12 @@ export const AudioRecorder = <
275
261
  >(
276
262
  props: AudioRecorderProps<StreamChatGenerics>,
277
263
  ) => {
278
- const { disabled = false } = useChannelContext<StreamChatGenerics>();
279
264
  const { asyncMessagesMultiSendEnabled } = useMessageInputContext<StreamChatGenerics>();
280
265
 
281
266
  return (
282
267
  <MemoizedAudioRecorder
283
268
  {...{
284
269
  asyncMessagesMultiSendEnabled,
285
- disabled,
286
270
  }}
287
271
  {...props}
288
272
  />
@@ -1,10 +1,6 @@
1
1
  import React from 'react';
2
2
  import { Alert, Linking, Pressable, StyleSheet } from 'react-native';
3
3
 
4
- import {
5
- ChannelContextValue,
6
- useChannelContext,
7
- } from '../../../../contexts/channelContext/ChannelContext';
8
4
  import {
9
5
  MessageInputContextValue,
10
6
  useMessageInputContext,
@@ -18,33 +14,32 @@ import type { DefaultStreamChatGenerics } from '../../../../types/types';
18
14
 
19
15
  type AudioRecordingButtonPropsWithContext<
20
16
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
21
- > = Pick<ChannelContextValue<StreamChatGenerics>, 'disabled'> &
22
- Pick<MessageInputContextValue<StreamChatGenerics>, 'asyncMessagesMinimumPressDuration'> & {
23
- /**
24
- * The current voice recording that is in progress.
25
- */
26
- recording: AudioRecordingReturnType;
27
- /**
28
- * Size of the mic button.
29
- */
30
- buttonSize?: number;
31
- /**
32
- * Handler to determine what should happen on long press of the mic button.
33
- */
34
- handleLongPress?: () => void;
35
- /**
36
- * Handler to determine what should happen on press of the mic button.
37
- */
38
- handlePress?: () => void;
39
- /**
40
- * Boolean to determine if the audio recording permissions are granted.
41
- */
42
- permissionsGranted?: boolean;
43
- /**
44
- * Function to start the voice recording.
45
- */
46
- startVoiceRecording?: () => Promise<void>;
47
- };
17
+ > = Pick<MessageInputContextValue<StreamChatGenerics>, 'asyncMessagesMinimumPressDuration'> & {
18
+ /**
19
+ * The current voice recording that is in progress.
20
+ */
21
+ recording: AudioRecordingReturnType;
22
+ /**
23
+ * Size of the mic button.
24
+ */
25
+ buttonSize?: number;
26
+ /**
27
+ * Handler to determine what should happen on long press of the mic button.
28
+ */
29
+ handleLongPress?: () => void;
30
+ /**
31
+ * Handler to determine what should happen on press of the mic button.
32
+ */
33
+ handlePress?: () => void;
34
+ /**
35
+ * Boolean to determine if the audio recording permissions are granted.
36
+ */
37
+ permissionsGranted?: boolean;
38
+ /**
39
+ * Function to start the voice recording.
40
+ */
41
+ startVoiceRecording?: () => Promise<void>;
42
+ };
48
43
 
49
44
  const AudioRecordingButtonWithContext = <
50
45
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
@@ -54,7 +49,6 @@ const AudioRecordingButtonWithContext = <
54
49
  const {
55
50
  asyncMessagesMinimumPressDuration,
56
51
  buttonSize,
57
- disabled,
58
52
  handleLongPress,
59
53
  handlePress,
60
54
  permissionsGranted,
@@ -107,7 +101,6 @@ const AudioRecordingButtonWithContext = <
107
101
  return (
108
102
  <Pressable
109
103
  delayLongPress={asyncMessagesMinimumPressDuration}
110
- disabled={disabled}
111
104
  onLongPress={onLongPressHandler}
112
105
  onPress={onPressHandler}
113
106
  style={({ pressed }) => [
@@ -132,12 +125,10 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
132
125
  ) => {
133
126
  const {
134
127
  asyncMessagesMinimumPressDuration: prevAsyncMessagesMinimumPressDuration,
135
- disabled: prevDisabled,
136
128
  recording: prevRecording,
137
129
  } = prevProps;
138
130
  const {
139
131
  asyncMessagesMinimumPressDuration: nextAsyncMessagesMinimumPressDuration,
140
- disabled: nextDisabled,
141
132
  recording: nextRecording,
142
133
  } = nextProps;
143
134
 
@@ -145,9 +136,6 @@ const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = Default
145
136
  prevAsyncMessagesMinimumPressDuration === nextAsyncMessagesMinimumPressDuration;
146
137
  if (!asyncMessagesMinimumPressDurationEqual) return false;
147
138
 
148
- const disabledEqual = prevDisabled === nextDisabled;
149
- if (!disabledEqual) return false;
150
-
151
139
  const recordingEqual = prevRecording === nextRecording;
152
140
  if (!recordingEqual) return false;
153
141
 
@@ -173,12 +161,9 @@ export const AudioRecordingButton = <
173
161
  >(
174
162
  props: AudioRecordingButtonProps<StreamChatGenerics>,
175
163
  ) => {
176
- const { disabled = false } = useChannelContext<StreamChatGenerics>();
177
164
  const { asyncMessagesMinimumPressDuration } = useMessageInputContext<StreamChatGenerics>();
178
165
 
179
- return (
180
- <MemoizedAudioRecordingButton {...{ asyncMessagesMinimumPressDuration, disabled }} {...props} />
181
- );
166
+ return <MemoizedAudioRecordingButton {...{ asyncMessagesMinimumPressDuration }} {...props} />;
182
167
  };
183
168
 
184
169
  const styles = StyleSheet.create({
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
3
3
 
4
- import type { ChannelContextValue } from '../../../contexts/channelContext/ChannelContext';
5
4
  import {
6
5
  MessageInputContextValue,
7
6
  useMessageInputContext,
@@ -25,19 +24,23 @@ const styles = StyleSheet.create({
25
24
  },
26
25
  });
27
26
 
28
- export type InputEditingStateHeaderPropsWithContext<
27
+ export type InputEditingStateHeaderProps<
29
28
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
30
- > = Pick<MessageInputContextValue<StreamChatGenerics>, 'clearEditingState' | 'resetInput'> &
31
- Pick<ChannelContextValue<StreamChatGenerics>, 'disabled'>;
29
+ > = Partial<Pick<MessageInputContextValue<StreamChatGenerics>, 'clearEditingState' | 'resetInput'>>;
32
30
 
33
- export const InputEditingStateHeaderWithContext = <
31
+ export const InputEditingStateHeader = <
34
32
  StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
35
33
  >({
36
- clearEditingState,
37
- disabled,
38
- resetInput,
39
- }: InputEditingStateHeaderPropsWithContext<StreamChatGenerics>) => {
34
+ clearEditingState: propClearEditingState,
35
+ resetInput: propResetInput,
36
+ }: InputEditingStateHeaderProps<StreamChatGenerics>) => {
40
37
  const { t } = useTranslationContext();
38
+ const { clearEditingState: contextClearEditingState, resetInput: contextResetInput } =
39
+ useMessageInputContext<StreamChatGenerics>();
40
+
41
+ const clearEditingState = propClearEditingState || contextClearEditingState;
42
+ const resetInput = propResetInput || contextResetInput;
43
+
41
44
  const {
42
45
  theme: {
43
46
  colors: { black, grey, grey_gainsboro },
@@ -54,10 +57,13 @@ export const InputEditingStateHeaderWithContext = <
54
57
  {t<string>('Editing Message')}
55
58
  </Text>
56
59
  <TouchableOpacity
57
- disabled={disabled}
58
60
  onPress={() => {
59
- resetInput();
60
- clearEditingState();
61
+ if (resetInput) {
62
+ resetInput();
63
+ }
64
+ if (clearEditingState) {
65
+ clearEditingState();
66
+ }
61
67
  }}
62
68
  testID='close-button'
63
69
  >
@@ -67,36 +73,4 @@ export const InputEditingStateHeaderWithContext = <
67
73
  );
68
74
  };
69
75
 
70
- const areEqual = <StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics>(
71
- prevProps: InputEditingStateHeaderPropsWithContext<StreamChatGenerics>,
72
- nextProps: InputEditingStateHeaderPropsWithContext<StreamChatGenerics>,
73
- ) => {
74
- const { disabled: prevDisabled } = prevProps;
75
- const { disabled: nextDisabled } = nextProps;
76
-
77
- const disabledEqual = prevDisabled === nextDisabled;
78
- if (!disabledEqual) return false;
79
-
80
- return true;
81
- };
82
-
83
- const MemoizedInputEditingStateHeader = React.memo(
84
- InputEditingStateHeaderWithContext,
85
- areEqual,
86
- ) as typeof InputEditingStateHeaderWithContext;
87
-
88
- export type InputEditingStateHeaderProps<
89
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
90
- > = Partial<InputEditingStateHeaderPropsWithContext<StreamChatGenerics>>;
91
-
92
- export const InputEditingStateHeader = <
93
- StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
94
- >(
95
- props: InputEditingStateHeaderProps<StreamChatGenerics>,
96
- ) => {
97
- const { clearEditingState, resetInput } = useMessageInputContext<StreamChatGenerics>();
98
-
99
- return <MemoizedInputEditingStateHeader {...{ clearEditingState, resetInput }} {...props} />;
100
- };
101
-
102
76
  InputEditingStateHeader.displayName = 'EditingStateHeader{messageInput}';