Doesn't autoplay new messages once if last message received was an autoplayed.

pull/1718/head
Warrick Corfe-Tan 4 years ago
parent da00ac8d44
commit 5a62fabd1c

@ -1,5 +1,5 @@
// Audio Player
import React, { useEffect, useRef } from 'react';
import React, { useEffect, useRef, useState } from 'react';
import H5AudioPlayer from 'react-h5-audio-player';
import { useSelector } from 'react-redux';
import { useTheme } from 'styled-components';
@ -39,7 +39,7 @@ export const AudioPlayerWithEncryptedFile = (props: {
if (
window.inboxStore?.getState().userConfig.audioAutoplay === true &&
props.playNextMessage &&
props.playableMessageIndex
props.playableMessageIndex !== undefined
) {
props.playNextMessage(props.playableMessageIndex);
}

@ -277,12 +277,15 @@ export class SessionMessagesList extends React.Component<Props, State> {
* @param index index of message that just completed
*/
const playNextMessage = (index: any) => {
const nextIndex = index - 1;
if (messages[nextIndex]) {
this.setState({
nextMessageToPlay: nextIndex,
});
let nextIndex: number | null = index - 1;
if (index <= 0 || messages.length < index - 1) {
nextIndex = null;
}
this.setState({
nextMessageToPlay: nextIndex,
});
};
if (messageProps) {

Loading…
Cancel
Save