|
1 | 1 | import React from 'react'; |
2 | 2 | import type { Attachment } from 'stream-chat'; |
3 | 3 |
|
4 | | -import { FileSizeIndicator } from './components'; |
| 4 | +import { FileSizeIndicator as DefaultFileSizeIndicator } from './components'; |
5 | 5 | import { FileIcon } from '../FileIcon'; |
6 | | -import { useMessageContext, useTranslationContext } from '../../context'; |
| 6 | +import { |
| 7 | + useComponentContext, |
| 8 | + useMessageContext, |
| 9 | + useTranslationContext, |
| 10 | +} from '../../context'; |
7 | 11 | import { |
8 | 12 | type AudioPlayer, |
9 | 13 | type AudioPlayerState, |
@@ -32,6 +36,7 @@ type VoiceRecordingPlayerUIProps = { |
32 | 36 |
|
33 | 37 | // todo: finish creating a BaseAudioPlayer derived from VoiceRecordingPlayerUI and AudioAttachmentUI |
34 | 38 | const VoiceRecordingPlayerUI = ({ audioPlayer }: VoiceRecordingPlayerUIProps) => { |
| 39 | + const { FileSizeIndicator = DefaultFileSizeIndicator } = useComponentContext(); |
35 | 40 | const { |
36 | 41 | canPlayRecord, |
37 | 42 | durationSeconds, |
@@ -130,31 +135,32 @@ export const VoiceRecordingPlayer = ({ |
130 | 135 |
|
131 | 136 | export type QuotedVoiceRecordingProps = Pick<VoiceRecordingProps, 'attachment'>; |
132 | 137 |
|
133 | | -export const QuotedVoiceRecording = ({ attachment }: QuotedVoiceRecordingProps) => ( |
134 | | - // const { t } = useTranslationContext(); |
135 | | - // const title = attachment.title || t('Voice message'); |
136 | | - <div className={rootClassName} data-testid='quoted-voice-recording-widget'> |
137 | | - <div className='str-chat__message-attachment__voice-recording-widget__metadata'> |
138 | | - <div className='str-chat__message-attachment__voice-recording-widget__audio-state'> |
139 | | - <div className='str-chat__message-attachment__voice-recording-widget__timer'> |
140 | | - {attachment.duration ? ( |
141 | | - <DurationDisplay |
142 | | - duration={attachment.duration} |
143 | | - isPlaying={false} |
144 | | - secondsElapsed={undefined} |
145 | | - /> |
146 | | - ) : ( |
147 | | - <FileSizeIndicator |
148 | | - fileSize={attachment.file_size} |
149 | | - maximumFractionDigits={0} |
150 | | - /> |
151 | | - )} |
| 138 | +export const QuotedVoiceRecording = ({ attachment }: QuotedVoiceRecordingProps) => { |
| 139 | + const { FileSizeIndicator = DefaultFileSizeIndicator } = useComponentContext(); |
| 140 | + return ( |
| 141 | + <div className={rootClassName} data-testid='quoted-voice-recording-widget'> |
| 142 | + <div className='str-chat__message-attachment__voice-recording-widget__metadata'> |
| 143 | + <div className='str-chat__message-attachment__voice-recording-widget__audio-state'> |
| 144 | + <div className='str-chat__message-attachment__voice-recording-widget__timer'> |
| 145 | + {attachment.duration ? ( |
| 146 | + <DurationDisplay |
| 147 | + duration={attachment.duration} |
| 148 | + isPlaying={false} |
| 149 | + secondsElapsed={undefined} |
| 150 | + /> |
| 151 | + ) : ( |
| 152 | + <FileSizeIndicator |
| 153 | + fileSize={attachment.file_size} |
| 154 | + maximumFractionDigits={0} |
| 155 | + /> |
| 156 | + )} |
| 157 | + </div> |
152 | 158 | </div> |
153 | 159 | </div> |
| 160 | + <FileIcon mimeType={attachment.mime_type} /> |
154 | 161 | </div> |
155 | | - <FileIcon mimeType={attachment.mime_type} /> |
156 | | - </div> |
157 | | -); |
| 162 | + ); |
| 163 | +}; |
158 | 164 |
|
159 | 165 | export type VoiceRecordingProps = { |
160 | 166 | /** The attachment object from the message's attachment list. */ |
|
0 commit comments