11import { useLocalStorage } from '@uidotdev/usehooks'
22import { Box , Button , Container , TextField , Typography } from '@mui/material'
3- import { useState } from 'react'
3+ import { useCallback , useState } from 'react'
44import { usePasswordProtectedEvent } from '../hooks/usePasswordProtectedEvent'
55import { useTalkSelection } from './useTalkSelection'
6- import { useAutoReloadAfterTalk } from './useAutoReloadAfterTalk '
6+ import { useAutoAdvanceAfterTalk } from './useAutoAdvanceAfterTalk '
77import { LiveTranscriptionView } from './LiveTranscriptionView'
88import { DateTime } from 'luxon'
99
@@ -21,8 +21,15 @@ export const TranscriptionApp = ({ eventId }: PublicEventTranscriptionProps) =>
2121
2222 const [ selectedTalk , upcomingTalks , resetSelectedTalk , setSelectedTalk ] = useTalkSelection ( selectedTrack , eventData )
2323
24- // Roll the screen over automatically 5 min after the current talk ends.
25- useAutoReloadAfterTalk ( selectedTalk ?. dateEnd )
24+ const advanceToNextTalk = useCallback ( ( ) => {
25+ if ( ! selectedTalk ) return
26+ const currentIndex = upcomingTalks . findIndex ( ( t ) => t . id === selectedTalk . id )
27+ const next = upcomingTalks [ currentIndex + 1 ]
28+ if ( next ) setSelectedTalk ( next )
29+ } , [ selectedTalk , upcomingTalks , setSelectedTalk ] )
30+
31+ // Roll over to the next talk automatically 5 min after the current one ends.
32+ useAutoAdvanceAfterTalk ( selectedTalk ?. dateEnd , advanceToNextTalk )
2633
2734 const saveStuffInLocalStorage = ( pagePassword : string , selectedTrack : string ) => {
2835 setSelectedTrack ( selectedTrack )
0 commit comments