File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -14,12 +14,17 @@ interface UseTranscriptionArgs {
1414 onTranscriptionStarted ?( ev : DailyEventObject < 'transcription-started' > ) : void ;
1515 onTranscriptionStopped ?( ev : DailyEventObject < 'transcription-stopped' > ) : void ;
1616 onTranscriptionError ?( ev : DailyEventObject < 'transcription-error' > ) : void ;
17+ /**
18+ * @deprecated Please use onTranscriptionMessage instead.
19+ */
1720 onTranscriptionAppData ?( ev : DailyEventObjectAppMessage < Transcription > ) : void ;
21+ onTranscriptionMessage ?( ev : DailyEventObject < 'transcription-message' > ) : void ;
1822}
1923
2024export const useTranscription = ( {
2125 onTranscriptionAppData,
2226 onTranscriptionError,
27+ onTranscriptionMessage,
2328 onTranscriptionStarted,
2429 onTranscriptionStopped,
2530} : UseTranscriptionArgs = { } ) => {
@@ -54,6 +59,15 @@ export const useTranscription = ({
5459 [ onTranscriptionError ]
5560 )
5661 ) ;
62+ useDailyEvent (
63+ 'transcription-message' ,
64+ useCallback (
65+ ( ev ) => {
66+ onTranscriptionMessage ?.( ev ) ;
67+ } ,
68+ [ onTranscriptionMessage ]
69+ )
70+ ) ;
5771 useDailyEvent (
5872 'app-message' ,
5973 useCallback (
Original file line number Diff line number Diff line change @@ -193,6 +193,31 @@ describe('useTranscription', () => {
193193 expect ( onTranscriptionAppData ) . toHaveBeenCalledWith ( payload ) ;
194194 } ) ;
195195 } ) ;
196+ it ( 'transcription-message data calls onTranscriptionMessage' , async ( ) => {
197+ const onTranscriptionMessage = jest . fn ( ) ;
198+ const daily = Daily . createCallObject ( ) ;
199+ const { waitFor } = renderHook (
200+ ( ) => useTranscription ( { onTranscriptionMessage } ) ,
201+ {
202+ wrapper : createWrapper ( daily ) ,
203+ }
204+ ) ;
205+ const event : DailyEvent = 'transcription-message' ;
206+ const payload : DailyEventObject < 'transcription-message' > = {
207+ action : 'transcription-message' ,
208+ participantId : faker . datatype . uuid ( ) ,
209+ text : 'Transcription text' ,
210+ timestamp : new Date ( ) ,
211+ rawResponse : { } ,
212+ } ;
213+ act ( ( ) => {
214+ // @ts -ignore
215+ daily . emit ( event , payload ) ;
216+ } ) ;
217+ await waitFor ( ( ) => {
218+ expect ( onTranscriptionMessage ) . toHaveBeenCalledWith ( payload ) ;
219+ } ) ;
220+ } ) ;
196221 it ( 'startTranscription calls daily.startTranscription' , async ( ) => {
197222 const daily = Daily . createCallObject ( ) ;
198223 const { result, waitFor } = renderHook ( ( ) => useTranscription ( ) , {
You can’t perform that action at this time.
0 commit comments