Skip to content

Commit e2b73b3

Browse files
committed
fix: switch to memo
1 parent 8d36646 commit e2b73b3

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,14 +642,19 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
642642
waveformData,
643643
} = useAudioController();
644644

645-
const isSendingButtonVisible = () => {
645+
const isSendingButtonVisible = useMemo(() => {
646+
console.log('IS SENDING VISIBLE: ', hasText);
647+
if (hasText) {
648+
return true;
649+
}
650+
if (sending.current) {
651+
return false;
652+
}
653+
646654
if (audioRecordingEnabled && isAudioRecorderAvailable()) {
647655
if (recording) {
648656
return false;
649657
}
650-
if (hasText) {
651-
return true;
652-
}
653658

654659
const imagesAndFiles = [...imageUploads, ...fileUploads];
655660
if (imagesAndFiles.length === 0) {
@@ -658,7 +663,7 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
658663
}
659664

660665
return true;
661-
};
666+
}, [audioRecordingEnabled, fileUploads, hasText, imageUploads, recording, sending]);
662667

663668
const micPositionX = useSharedValue(0);
664669
const micPositionY = useSharedValue(0);
@@ -864,7 +869,7 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
864869

865870
{shouldDisplayStopAIGeneration ? (
866871
<StopMessageStreamingButton onPress={stopGenerating} />
867-
) : isSendingButtonVisible() ? (
872+
) : isSendingButtonVisible ? (
868873
cooldownRemainingSeconds ? (
869874
<CooldownTimer seconds={cooldownRemainingSeconds} />
870875
) : (

0 commit comments

Comments
 (0)