|
|
@@ -6,7 +6,14 @@ import React, { PureComponent } from 'react';
|
|
6
|
6
|
import { View } from 'react-native';
|
|
7
|
7
|
import { withTheme } from 'react-native-paper';
|
|
8
|
8
|
|
|
|
9
|
+import { translate } from '../../../base/i18n';
|
|
9
|
10
|
import { Icon, IconVolumeEmpty } from '../../../base/icons';
|
|
|
11
|
+import {
|
|
|
12
|
+ getLocalParticipant,
|
|
|
13
|
+ getParticipantById
|
|
|
14
|
+} from '../../../base/participants';
|
|
|
15
|
+import { connect } from '../../../base/redux';
|
|
|
16
|
+import { setVolume } from '../../../participants-pane/actions.native';
|
|
10
|
17
|
import { VOLUME_SLIDER_SCALE } from '../../constants';
|
|
11
|
18
|
|
|
12
|
19
|
/**
|
|
|
@@ -15,11 +22,24 @@ import { VOLUME_SLIDER_SCALE } from '../../constants';
|
|
15
|
22
|
type Props = {
|
|
16
|
23
|
|
|
17
|
24
|
/**
|
|
18
|
|
- * The value of the audio slider should display at when the component first
|
|
19
|
|
- * mounts. Changes will be stored in state. The value should be a number
|
|
20
|
|
- * between 0 and 1.
|
|
|
25
|
+ * Whether the participant enters the conference silent.
|
|
21
|
26
|
*/
|
|
22
|
|
- initialValue: number,
|
|
|
27
|
+ _startSilent: boolean,
|
|
|
28
|
+
|
|
|
29
|
+ /**
|
|
|
30
|
+ * The volume level for the participant.
|
|
|
31
|
+ */
|
|
|
32
|
+ _volume: number,
|
|
|
33
|
+
|
|
|
34
|
+ /**
|
|
|
35
|
+ * The redux dispatch function.
|
|
|
36
|
+ */
|
|
|
37
|
+ dispatch: Function,
|
|
|
38
|
+
|
|
|
39
|
+ /**
|
|
|
40
|
+ * Participant reference
|
|
|
41
|
+ */
|
|
|
42
|
+ participant: Object,
|
|
23
|
43
|
|
|
24
|
44
|
/**
|
|
25
|
45
|
* Theme used for styles.
|
|
|
@@ -58,7 +78,7 @@ class VolumeSlider extends PureComponent<Props, State> {
|
|
58
|
78
|
super(props);
|
|
59
|
79
|
|
|
60
|
80
|
this.state = {
|
|
61
|
|
- volumeLevel: (props.initialValue || 0) * VOLUME_SLIDER_SCALE
|
|
|
81
|
+ volumeLevel: (props._volume || 0) * VOLUME_SLIDER_SCALE
|
|
62
|
82
|
};
|
|
63
|
83
|
|
|
64
|
84
|
this._originalVolumeChange = this._onVolumeChange;
|
|
|
@@ -75,9 +95,10 @@ class VolumeSlider extends PureComponent<Props, State> {
|
|
75
|
95
|
* @returns {ReactElement}
|
|
76
|
96
|
*/
|
|
77
|
97
|
render() {
|
|
78
|
|
- const { theme } = this.props;
|
|
|
98
|
+ const { _startSilent, theme } = this.props;
|
|
79
|
99
|
const { volumeLevel } = this.state;
|
|
80
|
100
|
const { palette } = theme;
|
|
|
101
|
+ const onVolumeChange = _startSilent ? undefined : this._onVolumeChange;
|
|
81
|
102
|
|
|
82
|
103
|
return (
|
|
83
|
104
|
<View>
|
|
|
@@ -89,7 +110,7 @@ class VolumeSlider extends PureComponent<Props, State> {
|
|
89
|
110
|
maximumValue = { VOLUME_SLIDER_SCALE }
|
|
90
|
111
|
minimumTrackTintColor = { palette.action01 }
|
|
91
|
112
|
minimumValue = { 0 }
|
|
92
|
|
- onValueChange = { this._onVolumeChange }
|
|
|
113
|
+ onValueChange = { onVolumeChange }
|
|
93
|
114
|
thumbTintColor = { palette.field02 }
|
|
94
|
115
|
value = { volumeLevel } />
|
|
95
|
116
|
</View>
|
|
|
@@ -106,9 +127,34 @@ class VolumeSlider extends PureComponent<Props, State> {
|
|
106
|
127
|
* @returns {void}
|
|
107
|
128
|
*/
|
|
108
|
129
|
_onVolumeChange(volumeLevel) {
|
|
109
|
|
- this.setState({ volumeLevel });
|
|
|
130
|
+ const { dispatch, participant } = this.props;
|
|
|
131
|
+ const { id } = participant;
|
|
|
132
|
+
|
|
|
133
|
+ dispatch(setVolume(id, volumeLevel));
|
|
110
|
134
|
}
|
|
111
|
135
|
}
|
|
112
|
136
|
|
|
113
|
|
-export default withTheme(VolumeSlider);
|
|
|
137
|
+/**
|
|
|
138
|
+ * Maps (parts of) the Redux state to the associated props for the
|
|
|
139
|
+ * {@code VolumeSlider} component.
|
|
|
140
|
+ *
|
|
|
141
|
+ * @param {Object} state - The Redux state.
|
|
|
142
|
+ * @param {Object} ownProps - The own props of the component.
|
|
|
143
|
+ * @returns {Props}
|
|
|
144
|
+ */
|
|
|
145
|
+function mapStateToProps(state, ownProps): Object {
|
|
|
146
|
+ const { participant } = ownProps;
|
|
|
147
|
+ const { startSilent } = state['features/base/config'];
|
|
|
148
|
+ const { participantsVolume } = state['features/participants-pane'];
|
|
|
149
|
+ const getParticipant = participant.id
|
|
|
150
|
+ ? getParticipantById(state, participant.id) : getLocalParticipant(state);
|
|
|
151
|
+ const { id } = getParticipant;
|
|
|
152
|
+
|
|
|
153
|
+ return {
|
|
|
154
|
+ _startSilent: Boolean(startSilent),
|
|
|
155
|
+ _volume: participant.local ? undefined : participantsVolume[id]
|
|
|
156
|
+ };
|
|
|
157
|
+}
|
|
|
158
|
+
|
|
|
159
|
+export default translate(connect(mapStateToProps)(withTheme(VolumeSlider)));
|
|
114
|
160
|
|