@@ -4,6 +4,8 @@ import { I18nManager, Pressable, StyleSheet, Text, View } from 'react-native';
44import dayjs from 'dayjs' ;
55import duration from 'dayjs/plugin/duration' ;
66
7+ import { AudioAttachment as StreamAudioAttachment } from 'stream-chat' ;
8+
79import { useTheme } from '../../contexts' ;
810import { useAudioPlayer } from '../../hooks/useAudioPlayer' ;
911import { Audio , Pause , Play } from '../../icons' ;
@@ -22,19 +24,18 @@ import { WaveProgressBar } from '../ProgressControl/WaveProgressBar';
2224
2325dayjs . extend ( duration ) ;
2426
25- export type AudioAttachmentType = AudioConfig & {
26- asset_url ?: string ;
27- id : string ;
28- title ?: string ;
29- type : 'audio' | 'voiceRecording' ;
30- waveform_data ?: number [ ] ;
31- } ;
27+ export type AudioAttachmentType = AudioConfig &
28+ Pick < StreamAudioAttachment , 'waveform_data' | 'asset_url' | 'title' > & {
29+ id : string ;
30+ type : 'audio' | 'voiceRecording' ;
31+ } ;
3232
3333export type AudioAttachmentProps = {
3434 item : AudioAttachmentType ;
3535 onLoad : ( index : string , duration : number ) => void ;
3636 onPlayPause : ( index : string , pausedStatus ?: boolean ) => void ;
3737 onProgress : ( index : string , progress : number ) => void ;
38+ titleMaxLength ?: number ;
3839 hideProgressBar ?: boolean ;
3940 showSpeedSettings ?: boolean ;
4041 testID ?: string ;
@@ -56,6 +57,7 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
5657 onProgress,
5758 showSpeedSettings = false ,
5859 testID,
60+ titleMaxLength,
5961 } = props ;
6062 const { changeAudioSpeed, pauseAudio, playAudio, seekAudio } = useAudioPlayer ( { soundRef } ) ;
6163 const isExpoCLI = NativeHandlers . SDK === 'stream-chat-expo' ;
@@ -263,7 +265,7 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
263265 } ,
264266 colors : { accent_blue, black, grey_dark, grey_whisper, static_black, static_white, white } ,
265267 messageInput : {
266- fileUploadPreview : { filenameText } ,
268+ fileAttachmentUploadPreview : { filenameText } ,
267269 } ,
268270 } ,
269271 } = useTheme ( ) ;
@@ -326,7 +328,9 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
326328 filenameText ,
327329 ] }
328330 >
329- { getTrimmedAttachmentTitle ( item . title ) }
331+ { item . type === FileTypes . VoiceRecording
332+ ? 'Recording'
333+ : getTrimmedAttachmentTitle ( item . title , titleMaxLength ) }
330334 </ Text >
331335 < View style = { styles . audioInfo } >
332336 < Text style = { [ styles . progressDurationText , { color : grey_dark } , progressDurationText ] } >
0 commit comments