linting and formatting.

pull/1718/head
Warrick Corfe-Tan 4 years ago
parent 397b0d09dc
commit 3bd72df258

@ -12,8 +12,8 @@ export const AudioPlayerWithEncryptedFile = (props: {
contentType: string; contentType: string;
playbackSpeed: number; playbackSpeed: number;
playNextMessage?: (index: number) => void; playNextMessage?: (index: number) => void;
playableMessageIndex?: number playableMessageIndex?: number;
nextMessageToPlay?: number nextMessageToPlay?: number;
}) => { }) => {
const theme = useTheme(); const theme = useTheme();
const { urlToLoad } = useEncryptedFileFetch(props.src, props.contentType); const { urlToLoad } = useEncryptedFileFetch(props.src, props.contentType);
@ -28,10 +28,10 @@ export const AudioPlayerWithEncryptedFile = (props: {
}, [playbackSpeed]); }, [playbackSpeed]);
useEffect(() => { useEffect(() => {
if (props.playableMessageIndex == props.nextMessageToPlay) { if (props.playableMessageIndex === props.nextMessageToPlay) {
player.current?.audio.current?.play(); player.current?.audio.current?.play();
} }
}) });
const onEnded = () => { const onEnded = () => {
// if audio autoplay is enabled, call method to start playing // if audio autoplay is enabled, call method to start playing
@ -43,7 +43,7 @@ export const AudioPlayerWithEncryptedFile = (props: {
) { ) {
props.playNextMessage(props.playableMessageIndex); props.playNextMessage(props.playableMessageIndex);
} }
} };
return ( return (
<H5AudioPlayer <H5AudioPlayer

@ -69,7 +69,7 @@ export class SessionMessagesList extends React.Component<Props, State> {
this.state = { this.state = {
showScrollButton: false, showScrollButton: false,
nextMessageToPlay: null nextMessageToPlay: null,
}; };
autoBind(this); autoBind(this);
@ -228,7 +228,6 @@ export class SessionMessagesList extends React.Component<Props, State> {
/> />
); );
currentMessageIndex = currentMessageIndex + 1; currentMessageIndex = currentMessageIndex + 1;
if (groupNotificationProps) { if (groupNotificationProps) {
@ -278,16 +277,16 @@ export class SessionMessagesList extends React.Component<Props, State> {
* @param index index of message that just completed * @param index index of message that just completed
*/ */
const playNextMessage = (index: any) => { const playNextMessage = (index: any) => {
index--; const nextIndex = index - 1;
if (messages[index]) { if (messages[nextIndex]) {
this.setState({ this.setState({
nextMessageToPlay: index nextMessageToPlay: nextIndex,
}) });
}
} }
};
if (messageProps) { if (messageProps) {
messageProps.nextMessageToPlay = this.state.nextMessageToPlay messageProps.nextMessageToPlay = this.state.nextMessageToPlay;
messageProps.playableMessageIndex = playableMessageIndex; messageProps.playableMessageIndex = playableMessageIndex;
messageProps.playNextMessage = playNextMessage; messageProps.playNextMessage = playNextMessage;
} }

@ -9,7 +9,7 @@ export interface UserConfigState {
} }
export const initialUserConfigState = { export const initialUserConfigState = {
audioAutoplay: false audioAutoplay: false,
}; };
const userConfigSlice = createSlice({ const userConfigSlice = createSlice({
@ -19,14 +19,14 @@ const userConfigSlice = createSlice({
updateUserConfig(state: UserConfigState, action: PayloadAction<UserConfigState>) { updateUserConfig(state: UserConfigState, action: PayloadAction<UserConfigState>) {
return { return {
...state, ...state,
audioAutoplay: true audioAutoplay: true,
} };
},
toggleAudioAutoplay: state => {
state.audioAutoplay = !state.audioAutoplay;
}, },
toggleAudioAutoplay: (state) => {
state.audioAutoplay = !state.audioAutoplay
}
}, },
}) });
const { actions, reducer } = userConfigSlice; const { actions, reducer } = userConfigSlice;
export const { updateUserConfig, toggleAudioAutoplay } = actions; export const { updateUserConfig, toggleAudioAutoplay } = actions;

@ -37,7 +37,7 @@ export const reducers = {
mentionsInput, mentionsInput,
onionPaths, onionPaths,
modals, modals,
userConfig userConfig,
}; };
// Making this work would require that our reducer signature supported AnyAction, not // Making this work would require that our reducer signature supported AnyAction, not

@ -1,10 +1,9 @@
import { StateType } from '../reducer'; import { StateType } from '../reducer';
import { UserConfigState } from "../ducks/userConfig"; import { UserConfigState } from '../ducks/userConfig';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
export const getUserConfig = (state: StateType): UserConfigState => state.userConfig; export const getUserConfig = (state: StateType): UserConfigState => state.userConfig;
export const getAudioAutoplay = createSelector( export const getAudioAutoplay = createSelector(
getUserConfig, getUserConfig,
(state: UserConfigState): boolean => state.audioAutoplay (state: UserConfigState): boolean => state.audioAutoplay

Loading…
Cancel
Save