diff --git a/examples/SampleApp/ios/Podfile.lock b/examples/SampleApp/ios/Podfile.lock index 48003e3ab3..61fc07eb9c 100644 --- a/examples/SampleApp/ios/Podfile.lock +++ b/examples/SampleApp/ios/Podfile.lock @@ -3584,7 +3584,7 @@ SPEC CHECKSUMS: op-sqlite: a7e46cfdaebeef219fd0e939332967af9fe6d406 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 - RCT-Folly: 59ec0ac1f2f39672a0c6e6cecdd39383b764646f + RCT-Folly: 846fda9475e61ec7bcbf8a3fe81edfcaeb090669 RCTDeprecation: 300c5eb91114d4339b0bb39505d0f4824d7299b7 RCTRequired: e0446b01093475b7082fbeee5d1ef4ad1fe20ac4 RCTTypeSafety: cb974efcdc6695deedf7bf1eb942f2a0603a063f diff --git a/examples/SampleApp/yarn.lock b/examples/SampleApp/yarn.lock index 9ab669def7..729973a1f4 100644 --- a/examples/SampleApp/yarn.lock +++ b/examples/SampleApp/yarn.lock @@ -8354,10 +8354,10 @@ stream-chat-react-native-core@8.1.0: version "0.0.0" uid "" -stream-chat@^9.33.0: - version "9.34.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.34.0.tgz#e92c3262e1b6fbe92b1b1148286ee152849250dc" - integrity sha512-b65Z+ufAtygAwT2dCQ8ImgMx01b9zgS1EZ8OK5lRHhSJKYKSsSa1pS3USbbFq6QpuwGZwXM3lovGXLYoWiG84g== +stream-chat@^9.35.1: + version "9.35.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.35.1.tgz#d828854a9c27ea7e45e6642d9107966c6606f552" + integrity sha512-649sgO7+llFuW+y/Ja0K4d94aUC+EMxYUVo5mq5AFGT86vUAIXmRIMVHYHA/jw4MYoqfWAFrDK6L9Rhyn/eMkQ== dependencies: "@types/jsonwebtoken" "^9.0.8" "@types/ws" "^8.5.14" diff --git a/package/package.json b/package/package.json index 67029cbc8a..ae2aa00e6b 100644 --- a/package/package.json +++ b/package/package.json @@ -80,7 +80,7 @@ "path": "0.12.7", "react-native-markdown-package": "1.8.2", "react-native-url-polyfill": "^2.0.0", - "stream-chat": "^9.33.0", + "stream-chat": "^9.35.1", "use-sync-external-store": "^1.5.0" }, "peerDependencies": { diff --git a/package/src/components/MessageInput/components/OutputButtons/index.tsx b/package/src/components/MessageInput/components/OutputButtons/index.tsx index 33dbdbe0e9..b4a92c904c 100644 --- a/package/src/components/MessageInput/components/OutputButtons/index.tsx +++ b/package/src/components/MessageInput/components/OutputButtons/index.tsx @@ -14,8 +14,8 @@ import { useMessageComposerHasSendableData, useTheme, } from '../../../../contexts'; +import { useHasAttachments } from '../../../../contexts/messageInputContext/hooks/useHasAttachments'; import { useMessageComposer } from '../../../../contexts/messageInputContext/hooks/useMessageComposer'; -import { useMessageCompositionIsEmpty } from '../../../../contexts/messageInputContext/hooks/useMessageCompositionIsEmpty'; import { MessageInputContextValue, useMessageInputContext, @@ -41,10 +41,12 @@ export type OutputButtonsWithContextProps = Pick & | 'StartAudioRecordingButton' > & { cooldownIsActive: boolean; + hasAttachments: boolean; }; const textComposerStateSelector = (state: TextComposerState) => ({ command: state.command, + textIsEmpty: !state.text, }); export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) => { @@ -57,6 +59,7 @@ export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) = SendButton, StopMessageStreamingButton, StartAudioRecordingButton, + hasAttachments, } = props; const { theme: { @@ -72,9 +75,8 @@ export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) = const messageComposer = useMessageComposer(); const editing = !!messageComposer.editedMessage; const { textComposer } = messageComposer; - const { command } = useStateStore(textComposer.state, textComposerStateSelector); + const { command, textIsEmpty } = useStateStore(textComposer.state, textComposerStateSelector); const hasSendableData = useMessageComposerHasSendableData(); - const compositionIsEmpty = useMessageCompositionIsEmpty(); const { aiState } = useAIState(channel); const stopGenerating = useCallback(() => channel?.stopAIResponse(), [channel]); @@ -105,7 +107,7 @@ export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) = ); - } else if (audioRecordingEnabled && compositionIsEmpty) { + } else if (audioRecordingEnabled && textIsEmpty && !hasAttachments) { return ( { - const { channel: prevChannel, cooldownIsActive: prevCooldownIsActive } = prevProps; + const { + channel: prevChannel, + cooldownIsActive: prevCooldownIsActive, + hasAttachments: prevHasAttachments, + } = prevProps; - const { channel: nextChannel, cooldownIsActive: nextCooldownIsActive } = nextProps; + const { + channel: nextChannel, + cooldownIsActive: nextCooldownIsActive, + hasAttachments: nextHasAttachments, + } = nextProps; if (prevChannel?.cid !== nextChannel?.cid) { return false; @@ -147,6 +157,11 @@ const areEqual = ( return false; } + const hasAttachmentsEqual = prevHasAttachments === nextHasAttachments; + if (!hasAttachmentsEqual) { + return false; + } + return true; }; @@ -170,6 +185,7 @@ export const OutputButtons = (props: OutputButtonsProps) => { StartAudioRecordingButton, } = useMessageInputContext(); const cooldownIsActive = useIsCooldownActive(); + const hasAttachments = useHasAttachments(); return ( { SendButton, StartAudioRecordingButton, StopMessageStreamingButton, + hasAttachments, }} {...props} /> diff --git a/package/yarn.lock b/package/yarn.lock index 13d79fbbbf..b472c39fcc 100644 --- a/package/yarn.lock +++ b/package/yarn.lock @@ -8352,10 +8352,10 @@ stdin-discarder@^0.2.2: resolved "https://registry.yarnpkg.com/stdin-discarder/-/stdin-discarder-0.2.2.tgz#390037f44c4ae1a1ae535c5fe38dc3aba8d997be" integrity sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ== -stream-chat@^9.33.0: - version "9.33.0" - resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.33.0.tgz#3da6582ade9a22a808abe7f443b08137705bf792" - integrity sha512-JdeR6Nq2QEKBIKZsW8wnGa04pTHCiWmdIOqvWUVJ4DtmLzJ9oBBeBnHvPx1Q+RKbvpZqfjwvYaCwKY5ZFq+FxQ== +stream-chat@^9.35.1: + version "9.35.1" + resolved "https://registry.yarnpkg.com/stream-chat/-/stream-chat-9.35.1.tgz#d828854a9c27ea7e45e6642d9107966c6606f552" + integrity sha512-649sgO7+llFuW+y/Ja0K4d94aUC+EMxYUVo5mq5AFGT86vUAIXmRIMVHYHA/jw4MYoqfWAFrDK6L9Rhyn/eMkQ== dependencies: "@types/jsonwebtoken" "^9.0.8" "@types/ws" "^8.5.14"