Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/SampleApp/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions examples/SampleApp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -41,10 +41,12 @@ export type OutputButtonsWithContextProps = Pick<ChatContextValue, 'isOnline'> &
| 'StartAudioRecordingButton'
> & {
cooldownIsActive: boolean;
hasAttachments: boolean;
};

const textComposerStateSelector = (state: TextComposerState) => ({
command: state.command,
textIsEmpty: !state.text,
});

export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) => {
Expand All @@ -57,6 +59,7 @@ export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) =
SendButton,
StopMessageStreamingButton,
StartAudioRecordingButton,
hasAttachments,
} = props;
const {
theme: {
Expand All @@ -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]);
Expand Down Expand Up @@ -105,7 +107,7 @@ export const OutputButtonsWithContext = (props: OutputButtonsWithContextProps) =
<CooldownTimer />
</Animated.View>
);
} else if (audioRecordingEnabled && compositionIsEmpty) {
} else if (audioRecordingEnabled && textIsEmpty && !hasAttachments) {
return (
<Animated.View
entering={ZoomIn.duration(200)}
Expand Down Expand Up @@ -134,9 +136,17 @@ const areEqual = (
prevProps: OutputButtonsWithContextProps,
nextProps: OutputButtonsWithContextProps,
) => {
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;
Expand All @@ -147,6 +157,11 @@ const areEqual = (
return false;
}

const hasAttachmentsEqual = prevHasAttachments === nextHasAttachments;
if (!hasAttachmentsEqual) {
return false;
}

return true;
};

Expand All @@ -170,6 +185,7 @@ export const OutputButtons = (props: OutputButtonsProps) => {
StartAudioRecordingButton,
} = useMessageInputContext();
const cooldownIsActive = useIsCooldownActive();
const hasAttachments = useHasAttachments();

return (
<MemoizedOutputButtonsWithContext
Expand All @@ -186,6 +202,7 @@ export const OutputButtons = (props: OutputButtonsProps) => {
SendButton,
StartAudioRecordingButton,
StopMessageStreamingButton,
hasAttachments,
}}
{...props}
/>
Expand Down
8 changes: 4 additions & 4 deletions package/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down