Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Refactor
AudioMessageRecorder
(#28019)
- Loading branch information
1 parent
d989e3a
commit e5055f0
Showing
4 changed files
with
80 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...teor/client/views/room/components/body/composer/messageBox/actions/AudioMessageAction.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { MessageComposerAction } from '@rocket.chat/ui-composer'; | ||
import { useTranslation } from '@rocket.chat/ui-contexts'; | ||
import type { AllHTMLAttributes } from 'react'; | ||
import React from 'react'; | ||
|
||
import type { ChatAPI } from '../../../../../../../lib/chats/ChatAPI'; | ||
import { useChat } from '../../../../../contexts/ChatContext'; | ||
|
||
type AudioMessageActionProps = { | ||
chatContext?: ChatAPI; | ||
} & Omit<AllHTMLAttributes<HTMLButtonElement>, 'is'>; | ||
|
||
const AudioMessageAction = ({ chatContext, ...props }: AudioMessageActionProps) => { | ||
const t = useTranslation(); | ||
const chat = useChat() ?? chatContext; | ||
|
||
const handleRecordButtonClick = () => chat?.composer?.setRecordingMode(true); | ||
|
||
return ( | ||
<MessageComposerAction | ||
title={t('Audio_message')} | ||
icon='mic' | ||
className='rc-message-box__icon rc-message-box__audio-message-mic' | ||
data-qa-id='audio-record' | ||
onClick={handleRecordButtonClick} | ||
{...props} | ||
/> | ||
); | ||
}; | ||
|
||
export default AudioMessageAction; |