feat(native-participants-pane) review remarks pt 2 volume slider
This commit is contained in:
parent
9b220f3870
commit
53d0a892b5
|
@ -26,12 +26,3 @@ export function isFilmstripVisible(stateful: Object | Function) {
|
||||||
return getParticipantCountWithFake(state) > 1;
|
return getParticipantCountWithFake(state) > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Selector used to get participants volume
|
|
||||||
*
|
|
||||||
* @param {Object} state - The global state.
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
export function getParticipantsVolume(state: Object) {
|
|
||||||
return state['features/filmstrip'].participantsVolume;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import React, { useCallback, useState } from 'react';
|
import React, { useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { TouchableOpacity, View } from 'react-native';
|
import { TouchableOpacity, View } from 'react-native';
|
||||||
import { Divider, Text } from 'react-native-paper';
|
import { Divider, Text } from 'react-native-paper';
|
||||||
|
@ -20,7 +20,6 @@ import {
|
||||||
} from '../../../base/participants';
|
} from '../../../base/participants';
|
||||||
import { getIsParticipantVideoMuted } from '../../../base/tracks';
|
import { getIsParticipantVideoMuted } from '../../../base/tracks';
|
||||||
import { openChat } from '../../../chat/actions.native';
|
import { openChat } from '../../../chat/actions.native';
|
||||||
import { getParticipantsVolume } from '../../../filmstrip';
|
|
||||||
import {
|
import {
|
||||||
KickRemoteParticipantDialog,
|
KickRemoteParticipantDialog,
|
||||||
MuteEveryoneDialog,
|
MuteEveryoneDialog,
|
||||||
|
@ -40,17 +39,14 @@ type Props = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props) => {
|
export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props) => {
|
||||||
const [ volume, setVolume ] = useState(0);
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
|
const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
|
||||||
const participantsVolume = useSelector(getParticipantsVolume)[p.id];
|
const isStartingSilent = useSelector(getIsStartingSilent);
|
||||||
const changeVolume = useCallback(() => {
|
const participantsVolume = 1;
|
||||||
setVolume(volume + 1);
|
const initialParticipantsVolume = isStartingSilent ? undefined : participantsVolume;
|
||||||
}, [ volume ]);
|
|
||||||
const displayName = p.name;
|
const displayName = p.name;
|
||||||
const isLocalModerator = useSelector(isLocalParticipantModerator);
|
const isLocalModerator = useSelector(isLocalParticipantModerator);
|
||||||
const isParticipantVideoMuted = useSelector(getIsParticipantVideoMuted(p));
|
const isParticipantVideoMuted = useSelector(getIsParticipantVideoMuted(p));
|
||||||
const isStartingSilent = useSelector(getIsStartingSilent);
|
|
||||||
|
|
||||||
const kickRemoteParticipant = useCallback(() => {
|
const kickRemoteParticipant = useCallback(() => {
|
||||||
dispatch(openDialog(KickRemoteParticipantDialog, {
|
dispatch(openDialog(KickRemoteParticipantDialog, {
|
||||||
|
@ -72,7 +68,7 @@ export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props)
|
||||||
participantID: p.id
|
participantID: p.id
|
||||||
}));
|
}));
|
||||||
}, [ dispatch, p ]);
|
}, [ dispatch, p ]);
|
||||||
const onVolumeChange = isStartingSilent ? undefined : changeVolume;
|
|
||||||
const sendPrivateMessage = useCallback(() => {
|
const sendPrivateMessage = useCallback(() => {
|
||||||
dispatch(hideDialog());
|
dispatch(hideDialog());
|
||||||
dispatch(openChat(p));
|
dispatch(openChat(p));
|
||||||
|
@ -177,8 +173,7 @@ export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props)
|
||||||
{/* </TouchableOpacity>*/}
|
{/* </TouchableOpacity>*/}
|
||||||
<Divider style = { styles.divider } />
|
<Divider style = { styles.divider } />
|
||||||
<VolumeSlider
|
<VolumeSlider
|
||||||
initialValue = { participantsVolume }
|
initialValue = { initialParticipantsVolume } />
|
||||||
onChange = { onVolumeChange } />
|
|
||||||
</BottomSheet>
|
</BottomSheet>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,13 +10,12 @@ import { admitMultiple } from '../../../lobby/actions.native';
|
||||||
import { getLobbyState } from '../../../lobby/functions';
|
import { getLobbyState } from '../../../lobby/functions';
|
||||||
|
|
||||||
import { LobbyParticipantItem } from './LobbyParticipantItem';
|
import { LobbyParticipantItem } from './LobbyParticipantItem';
|
||||||
import { participants } from './participants';
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
|
|
||||||
export const LobbyParticipantList = () => {
|
export const LobbyParticipantList = () => {
|
||||||
const {
|
const {
|
||||||
lobbyEnabled,
|
lobbyEnabled,
|
||||||
knockingParticipants
|
knockingParticipants: participants
|
||||||
} = useSelector(getLobbyState);
|
} = useSelector(getLobbyState);
|
||||||
|
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
@ -25,9 +24,9 @@ export const LobbyParticipantList = () => {
|
||||||
[ dispatch ]);
|
[ dispatch ]);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
// if (!lobbyEnabled || !participants.length) {
|
if (!lobbyEnabled || !participants.length) {
|
||||||
// return null;
|
return null;
|
||||||
// }
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style = { styles.lobbyList }>
|
<View style = { styles.lobbyList }>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import Slider from '@react-native-community/slider';
|
import Slider from '@react-native-community/slider';
|
||||||
|
import _ from 'lodash';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { View } from 'react-native';
|
import { View } from 'react-native';
|
||||||
import { withTheme } from 'react-native-paper';
|
import { withTheme } from 'react-native-paper';
|
||||||
|
@ -20,11 +21,6 @@ type Props = {
|
||||||
*/
|
*/
|
||||||
initialValue: number,
|
initialValue: number,
|
||||||
|
|
||||||
/**
|
|
||||||
* The callback to invoke when the audio slider value changes.
|
|
||||||
*/
|
|
||||||
onChange: Function,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Theme used for styles.
|
* Theme used for styles.
|
||||||
*/
|
*/
|
||||||
|
@ -49,6 +45,8 @@ type State = {
|
||||||
* @returns {React$Element<any>}
|
* @returns {React$Element<any>}
|
||||||
*/
|
*/
|
||||||
class VolumeSlider extends Component<Props, State> {
|
class VolumeSlider extends Component<Props, State> {
|
||||||
|
_onVolumeChange: Function;
|
||||||
|
_originalVolumeChange: Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a new {@code VolumeSlider} instance.
|
* Initializes a new {@code VolumeSlider} instance.
|
||||||
|
@ -63,8 +61,11 @@ class VolumeSlider extends Component<Props, State> {
|
||||||
volumeLevel: (props.initialValue || 0) * VOLUME_SLIDER_SCALE
|
volumeLevel: (props.initialValue || 0) * VOLUME_SLIDER_SCALE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bind event handlers so they are only bound once for every instance.
|
this._originalVolumeChange = this._onVolumeChange;
|
||||||
this._onVolumeChange = this._onVolumeChange.bind(this);
|
|
||||||
|
this._onVolumeChange = _.throttle(
|
||||||
|
volumeLevel => this._originalVolumeChange(volumeLevel), 500
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,8 +97,6 @@ class VolumeSlider extends Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
_onVolumeChange: (Object) => void;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the internal state of the volume level for the volume slider.
|
* Sets the internal state of the volume level for the volume slider.
|
||||||
* Invokes the prop onVolumeChange to notify of volume changes.
|
* Invokes the prop onVolumeChange to notify of volume changes.
|
||||||
|
@ -107,9 +106,6 @@ class VolumeSlider extends Component<Props, State> {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_onVolumeChange(volumeLevel) {
|
_onVolumeChange(volumeLevel) {
|
||||||
const { onChange } = this.props;
|
|
||||||
|
|
||||||
onChange(volumeLevel / VOLUME_SLIDER_SCALE);
|
|
||||||
this.setState({ volumeLevel });
|
this.setState({ volumeLevel });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue