mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Audio autoplay stop when sent from a different user.
This commit is contained in:
parent
281b72cca0
commit
184c4d5d3e
|
@ -279,7 +279,21 @@ export class SessionMessagesList extends React.Component<Props, State> {
|
|||
const playNextMessage = (index: any) => {
|
||||
let nextIndex: number | null = index - 1;
|
||||
|
||||
if (index <= 0 || messages.length < index - 1) {
|
||||
// to prevent autoplaying as soon as a message is received.
|
||||
const latestMessagePlayed = index <= 0 || messages.length < index - 1;
|
||||
if (latestMessagePlayed) {
|
||||
nextIndex = null;
|
||||
this.setState({
|
||||
nextMessageToPlay: nextIndex,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// stop auto-playing when the audio messages change author.
|
||||
const prevAuthorNumber = messages[index].propsForMessage.authorPhoneNumber;
|
||||
const nextAuthorNumber = messages[index - 1].propsForMessage.authorPhoneNumber;
|
||||
const differentAuthor = prevAuthorNumber !== nextAuthorNumber;
|
||||
if (differentAuthor) {
|
||||
nextIndex = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue