mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
Minor tidying.
This commit is contained in:
parent
d35f3f9e62
commit
856ced056a
|
@ -11,9 +11,8 @@ export const AudioPlayerWithEncryptedFile = (props: {
|
|||
src: string;
|
||||
contentType: string;
|
||||
playbackSpeed: number;
|
||||
changeTestList?: any;
|
||||
shouldPlay?: boolean
|
||||
index?: number
|
||||
playNextMessage?: (index: number) => void;
|
||||
playableMessageIndex?: number
|
||||
nextMessageToPlay?: number
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
|
@ -29,14 +28,20 @@ export const AudioPlayerWithEncryptedFile = (props: {
|
|||
}, [playbackSpeed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.index == props.nextMessageToPlay) {
|
||||
if (props.playableMessageIndex == props.nextMessageToPlay) {
|
||||
player.current?.audio.current?.play();
|
||||
}
|
||||
})
|
||||
|
||||
const onEnded = () => {
|
||||
if (window.inboxStore?.getState().userConfig.audioAutoplay === true) {
|
||||
props.changeTestList(props.index);
|
||||
// if audio autoplay is enabled, call method to start playing
|
||||
// the next playable message
|
||||
if (
|
||||
window.inboxStore?.getState().userConfig.audioAutoplay === true &&
|
||||
props.playNextMessage &&
|
||||
props.playableMessageIndex
|
||||
) {
|
||||
props.playNextMessage(props.playableMessageIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -202,9 +202,8 @@ class MessageInner extends React.PureComponent<MessageRegularProps, State> {
|
|||
playbackSpeed={this.state.playbackSpeed}
|
||||
src={firstAttachment.url}
|
||||
contentType={firstAttachment.contentType}
|
||||
changeTestList={this.props.changeTestList}
|
||||
shouldPlay={this.props.shouldPlay}
|
||||
index={this.props.index}
|
||||
playNextMessage={this.props.playNextMessage}
|
||||
playableMessageIndex={this.props.playableMessageIndex}
|
||||
nextMessageToPlay={this.props.nextMessageToPlay}
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -273,7 +273,11 @@ export class SessionMessagesList extends React.Component<Props, State> {
|
|||
return;
|
||||
}
|
||||
|
||||
const changeTestList = (index: any) => {
|
||||
/**
|
||||
* Sets the targeted index for the next
|
||||
* @param index index of message that just completed
|
||||
*/
|
||||
const playNextMessage = (index: any) => {
|
||||
index--;
|
||||
if (messages[index]) {
|
||||
this.setState({
|
||||
|
@ -284,8 +288,8 @@ export class SessionMessagesList extends React.Component<Props, State> {
|
|||
|
||||
if (messageProps) {
|
||||
messageProps.nextMessageToPlay = this.state.nextMessageToPlay
|
||||
messageProps.index = playableMessageIndex;
|
||||
messageProps.changeTestList = changeTestList;
|
||||
messageProps.playableMessageIndex = playableMessageIndex;
|
||||
messageProps.playNextMessage = playNextMessage;
|
||||
}
|
||||
playableMessageIndex++;
|
||||
|
||||
|
|
|
@ -253,8 +253,7 @@ export interface MessageRegularProps {
|
|||
markRead: (readAt: number) => Promise<void>;
|
||||
theme: DefaultTheme;
|
||||
|
||||
shouldPlay?: boolean;
|
||||
index?: number;
|
||||
playableMessageIndex?: number;
|
||||
nextMessageToPlay?: number;
|
||||
changeTestList: (value: any) => any;
|
||||
playNextMessage?: (value: number) => any;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue