|  |  | @ -5,7 +5,7 @@ import { useDispatch, useSelector } from 'react-redux'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import styled from 'styled-components'; |  |  |  | import styled from 'styled-components'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { useEncryptedFileFetch } from '../../hooks/useEncryptedFileFetch'; |  |  |  | import { useEncryptedFileFetch } from '../../hooks/useEncryptedFileFetch'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { setNextMessageToPlayId } from '../../state/ducks/conversations'; |  |  |  | import { setNextMessageToPlayId } from '../../state/ducks/conversations'; | 
			
		
	
		
		
			
				
					
					|  |  |  | import { useMessageSelected } from '../../state/selectors'; |  |  |  | import { useMessageDirection, useMessageSelected } from '../../state/selectors'; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | import { |  |  |  | import { | 
			
		
	
		
		
			
				
					
					|  |  |  |   getNextMessageToPlayId, |  |  |  |   getNextMessageToPlayId, | 
			
		
	
		
		
			
				
					
					|  |  |  |   getSortedMessagesOfSelectedConversation, |  |  |  |   getSortedMessagesOfSelectedConversation, | 
			
		
	
	
		
		
			
				
					|  |  | @ -166,37 +166,13 @@ export const AudioPlayerWithEncryptedFile = (props: { | 
			
		
	
		
		
			
				
					
					|  |  |  |   const nextMessageToPlayId = useSelector(getNextMessageToPlayId); |  |  |  |   const nextMessageToPlayId = useSelector(getNextMessageToPlayId); | 
			
		
	
		
		
			
				
					
					|  |  |  |   const multiSelectMode = useSelector(isMessageSelectionMode); |  |  |  |   const multiSelectMode = useSelector(isMessageSelectionMode); | 
			
		
	
		
		
			
				
					
					|  |  |  |   const selected = useMessageSelected(messageId); |  |  |  |   const selected = useMessageSelected(messageId); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |   const direction = useMessageDirection(messageId); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   const iconColor = | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     direction === 'incoming' | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       ? 'var(--message-bubbles-received-text-color)' | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       : 'var(--message-bubbles-sent-text-color)'; | 
			
		
	
		
		
			
				
					
					|  |  |  |   const dataTestId = `audio-${messageId}`; |  |  |  |   const dataTestId = `audio-${messageId}`; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   useEffect(() => { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     // Updates datatestId once rendered
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if ( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current?.audio.current && |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current?.container.current && |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current.container.current.dataset.testId !== dataTestId |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       // NOTE we can't assign the value using dataset.testId because the result is data-test-id not data-testid which is our convention
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current.container.current.setAttribute('data-testid', dataTestId); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, [dataTestId, player]); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   useEffect(() => { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     // updates playback speed to value selected in context menu
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if ( |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current?.audio.current && |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current?.audio.current?.playbackRate !== playbackSpeed |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     ) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       player.current.audio.current.playbackRate = playbackSpeed; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, [playbackSpeed, player]); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   useEffect(() => { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     if (messageId !== undefined && messageId === nextMessageToPlayId) { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |       void player.current?.audio.current?.play(); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   }, [messageId, nextMessageToPlayId, player]); |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |   const triggerPlayNextMessageIfNeeded = (endedMessageId: string) => { |  |  |  |   const triggerPlayNextMessageIfNeeded = (endedMessageId: string) => { | 
			
		
	
		
		
			
				
					
					|  |  |  |     const justEndedMessageIndex = messageProps.findIndex( |  |  |  |     const justEndedMessageIndex = messageProps.findIndex( | 
			
		
	
		
		
			
				
					
					|  |  |  |       m => m.propsForMessage.id === endedMessageId |  |  |  |       m => m.propsForMessage.id === endedMessageId | 
			
		
	
	
		
		
			
				
					|  |  | @ -237,6 +213,34 @@ export const AudioPlayerWithEncryptedFile = (props: { | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |   }; |  |  |  |   }; | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   useEffect(() => { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     // Updates datatestId once rendered
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if ( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current?.audio.current && | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current?.container.current && | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current.container.current.dataset.testId !== dataTestId | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       // NOTE we can't assign the value using dataset.testId because the result is data-test-id not data-testid which is our convention
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current.container.current.setAttribute('data-testid', dataTestId); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   }, [dataTestId, player]); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   useEffect(() => { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     // updates playback speed to value selected in context menu
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if ( | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current?.audio.current && | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current?.audio.current?.playbackRate !== playbackSpeed | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       player.current.audio.current.playbackRate = playbackSpeed; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   }, [playbackSpeed, player]); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   useEffect(() => { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     if (messageId !== undefined && messageId === nextMessageToPlayId) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |       void player.current?.audio.current?.play(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |   }, [messageId, nextMessageToPlayId, player]); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |   return ( |  |  |  |   return ( | 
			
		
	
		
		
			
				
					
					|  |  |  |     <StyledH5AudioPlayer |  |  |  |     <StyledH5AudioPlayer | 
			
		
	
		
		
			
				
					
					|  |  |  |       src={urlToLoad} |  |  |  |       src={urlToLoad} | 
			
		
	
	
		
		
			
				
					|  |  | @ -264,8 +268,8 @@ export const AudioPlayerWithEncryptedFile = (props: { | 
			
		
	
		
		
			
				
					
					|  |  |  |         </StyledSpeedButton>, |  |  |  |         </StyledSpeedButton>, | 
			
		
	
		
		
			
				
					
					|  |  |  |       ]} |  |  |  |       ]} | 
			
		
	
		
		
			
				
					
					|  |  |  |       customIcons={{ |  |  |  |       customIcons={{ | 
			
		
	
		
		
			
				
					
					|  |  |  |         play: <SessionIcon iconType="play" iconSize="small" />, |  |  |  |         play: <SessionIcon iconType="play" iconSize="small" iconColor={iconColor} />, | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         pause: <SessionIcon iconType="pause" iconSize="small" />, |  |  |  |         pause: <SessionIcon iconType="pause" iconSize="small" iconColor={iconColor} />, | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |       }} |  |  |  |       }} | 
			
		
	
		
		
			
				
					
					|  |  |  |       dropShadow={selected} |  |  |  |       dropShadow={selected} | 
			
		
	
		
		
			
				
					
					|  |  |  |     /> |  |  |  |     /> | 
			
		
	
	
		
		
			
				
					|  |  | 
 |