linting and formatting.
This commit is contained in:
parent
397b0d09dc
commit
3bd72df258
|
@ -12,8 +12,8 @@ export const AudioPlayerWithEncryptedFile = (props: {
|
|||
contentType: string;
|
||||
playbackSpeed: number;
|
||||
playNextMessage?: (index: number) => void;
|
||||
playableMessageIndex?: number
|
||||
nextMessageToPlay?: number
|
||||
playableMessageIndex?: number;
|
||||
nextMessageToPlay?: number;
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const { urlToLoad } = useEncryptedFileFetch(props.src, props.contentType);
|
||||
|
@ -28,13 +28,13 @@ export const AudioPlayerWithEncryptedFile = (props: {
|
|||
}, [playbackSpeed]);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.playableMessageIndex == props.nextMessageToPlay) {
|
||||
if (props.playableMessageIndex === props.nextMessageToPlay) {
|
||||
player.current?.audio.current?.play();
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const onEnded = () => {
|
||||
// if audio autoplay is enabled, call method to start playing
|
||||
// if audio autoplay is enabled, call method to start playing
|
||||
// the next playable message
|
||||
if (
|
||||
window.inboxStore?.getState().userConfig.audioAutoplay === true &&
|
||||
|
@ -43,7 +43,7 @@ export const AudioPlayerWithEncryptedFile = (props: {
|
|||
) {
|
||||
props.playNextMessage(props.playableMessageIndex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<H5AudioPlayer
|
||||
|
|
|
@ -69,7 +69,7 @@ export class SessionMessagesList extends React.Component<Props, State> {
|
|||
|
||||
this.state = {
|
||||
showScrollButton: false,
|
||||
nextMessageToPlay: null
|
||||
nextMessageToPlay: null,
|
||||
};
|
||||
autoBind(this);
|
||||
|
||||
|
@ -228,7 +228,6 @@ export class SessionMessagesList extends React.Component<Props, State> {
|
|||
/>
|
||||
);
|
||||
|
||||
|
||||
currentMessageIndex = currentMessageIndex + 1;
|
||||
|
||||
if (groupNotificationProps) {
|
||||
|
@ -274,20 +273,20 @@ export class SessionMessagesList extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the targeted index for the next
|
||||
* Sets the targeted index for the next
|
||||
* @param index index of message that just completed
|
||||
*/
|
||||
const playNextMessage = (index: any) => {
|
||||
index--;
|
||||
if (messages[index]) {
|
||||
const nextIndex = index - 1;
|
||||
if (messages[nextIndex]) {
|
||||
this.setState({
|
||||
nextMessageToPlay: index
|
||||
})
|
||||
nextMessageToPlay: nextIndex,
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (messageProps) {
|
||||
messageProps.nextMessageToPlay = this.state.nextMessageToPlay
|
||||
messageProps.nextMessageToPlay = this.state.nextMessageToPlay;
|
||||
messageProps.playableMessageIndex = playableMessageIndex;
|
||||
messageProps.playNextMessage = playNextMessage;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ export interface UserConfigState {
|
|||
}
|
||||
|
||||
export const initialUserConfigState = {
|
||||
audioAutoplay: false
|
||||
audioAutoplay: false,
|
||||
};
|
||||
|
||||
const userConfigSlice = createSlice({
|
||||
|
@ -19,15 +19,15 @@ const userConfigSlice = createSlice({
|
|||
updateUserConfig(state: UserConfigState, action: PayloadAction<UserConfigState>) {
|
||||
return {
|
||||
...state,
|
||||
audioAutoplay: true
|
||||
}
|
||||
audioAutoplay: true,
|
||||
};
|
||||
},
|
||||
toggleAudioAutoplay: state => {
|
||||
state.audioAutoplay = !state.audioAutoplay;
|
||||
},
|
||||
toggleAudioAutoplay: (state) => {
|
||||
state.audioAutoplay = !state.audioAutoplay
|
||||
}
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
const { actions, reducer } = userConfigSlice;
|
||||
export const { updateUserConfig, toggleAudioAutoplay } = actions;
|
||||
export const userConfigReducer = reducer;
|
||||
export const userConfigReducer = reducer;
|
||||
|
|
|
@ -37,7 +37,7 @@ export const reducers = {
|
|||
mentionsInput,
|
||||
onionPaths,
|
||||
modals,
|
||||
userConfig
|
||||
userConfig,
|
||||
};
|
||||
|
||||
// Making this work would require that our reducer signature supported AnyAction, not
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import { StateType } from '../reducer';
|
||||
import { UserConfigState } from "../ducks/userConfig";
|
||||
import { UserConfigState } from '../ducks/userConfig';
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
export const getUserConfig = (state: StateType): UserConfigState => state.userConfig;
|
||||
|
||||
|
||||
export const getAudioAutoplay = createSelector(
|
||||
getUserConfig,
|
||||
(state: UserConfigState): boolean => state.audioAutoplay
|
||||
);
|
||||
getUserConfig,
|
||||
(state: UserConfigState): boolean => state.audioAutoplay
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue