Skip to content

Commit 82c4b65

Browse files
authored
fix: Disabling voice message input submit button (#428)
[UIKIT-3327](https://sendbird.atlassian.net/browse/UIKIT-3327) * Compare minRecordTime and currentValue only when recording audio to disable submit button on the VoiceMessageInput component.
1 parent 79cc5ee commit 82c4b65

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ui/VoiceMessageInput/index.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,14 @@ export const VoiceMessageInput = ({
3939
const [lastClickTime, setLastClickTime] = useState<number>(0);
4040
const isReadyToRecord = useMemo(() => currentType === VoiceMessageInputStatus.READY_TO_RECORD, [currentType]);
4141
const isRecording = useMemo(() => currentType === VoiceMessageInputStatus.RECORDING, [currentType]);
42-
const isSendButtonDisabled = useMemo(() => (
43-
(isRecording || isReadyToRecord) && minRecordTime > currentValue
44-
), [isRecording, minRecordTime, currentValue]);
42+
const isSendButtonDisabled = useMemo(() => {
43+
if (currentType === VoiceMessageInputStatus.READY_TO_RECORD
44+
|| currentType === VoiceMessageInputStatus.RECORDING
45+
) {
46+
return minRecordTime > currentValue
47+
}
48+
return false;
49+
}, [currentType, minRecordTime, currentValue]);
4550
const isPlayMode = useMemo(() => {
4651
return (
4752
currentType === VoiceMessageInputStatus.READY_TO_PLAY
@@ -59,7 +64,6 @@ export const VoiceMessageInput = ({
5964
};
6065
const handleOnControlClick = useCallback(() => {
6166
const currentTime = Date.now();
62-
console.log(currentTime - lastClickTime, VOICE_RECORDER_CLICK_BUFFER_TIME)
6367
if (currentTime - lastClickTime > VOICE_RECORDER_CLICK_BUFFER_TIME) {
6468
onControlClick(currentType);
6569
setLastClickTime(currentTime);

0 commit comments

Comments
 (0)