Explorar el Código

feat(native-participants-pane) review remarks pt 2 volume slider

master
Calin Chitu hace 3 años
padre
commit
53d0a892b5

+ 0
- 9
react/features/filmstrip/functions.native.js Ver fichero

@@ -26,12 +26,3 @@ export function isFilmstripVisible(stateful: Object | Function) {
26 26
     return getParticipantCountWithFake(state) > 1;
27 27
 }
28 28
 
29
-/**
30
- * Selector used to get participants volume
31
- *
32
- * @param {Object} state - The global state.
33
- * @returns {string}
34
- */
35
-export function getParticipantsVolume(state: Object) {
36
-    return state['features/filmstrip'].participantsVolume;
37
-}

+ 6
- 11
react/features/participants-pane/components/native/ContextMenuMeetingParticipantDetails.js Ver fichero

@@ -1,6 +1,6 @@
1 1
 // @flow
2 2
 
3
-import React, { useCallback, useState } from 'react';
3
+import React, { useCallback } from 'react';
4 4
 import { useTranslation } from 'react-i18next';
5 5
 import { TouchableOpacity, View } from 'react-native';
6 6
 import { Divider, Text } from 'react-native-paper';
@@ -20,7 +20,6 @@ import {
20 20
 } from '../../../base/participants';
21 21
 import { getIsParticipantVideoMuted } from '../../../base/tracks';
22 22
 import { openChat } from '../../../chat/actions.native';
23
-import { getParticipantsVolume } from '../../../filmstrip';
24 23
 import {
25 24
     KickRemoteParticipantDialog,
26 25
     MuteEveryoneDialog,
@@ -40,17 +39,14 @@ type Props = {
40 39
 };
41 40
 
42 41
 export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props) => {
43
-    const [ volume, setVolume ] = useState(0);
44 42
     const dispatch = useDispatch();
45 43
     const cancel = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
46
-    const participantsVolume = useSelector(getParticipantsVolume)[p.id];
47
-    const changeVolume = useCallback(() => {
48
-        setVolume(volume + 1);
49
-    }, [ volume ]);
44
+    const isStartingSilent = useSelector(getIsStartingSilent);
45
+    const participantsVolume = 1;
46
+    const initialParticipantsVolume = isStartingSilent ? undefined : participantsVolume;
50 47
     const displayName = p.name;
51 48
     const isLocalModerator = useSelector(isLocalParticipantModerator);
52 49
     const isParticipantVideoMuted = useSelector(getIsParticipantVideoMuted(p));
53
-    const isStartingSilent = useSelector(getIsStartingSilent);
54 50
 
55 51
     const kickRemoteParticipant = useCallback(() => {
56 52
         dispatch(openDialog(KickRemoteParticipantDialog, {
@@ -72,7 +68,7 @@ export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props)
72 68
             participantID: p.id
73 69
         }));
74 70
     }, [ dispatch, p ]);
75
-    const onVolumeChange = isStartingSilent ? undefined : changeVolume;
71
+
76 72
     const sendPrivateMessage = useCallback(() => {
77 73
         dispatch(hideDialog());
78 74
         dispatch(openChat(p));
@@ -177,8 +173,7 @@ export const ContextMenuMeetingParticipantDetails = ({ participant: p }: Props)
177 173
             {/* </TouchableOpacity>*/}
178 174
             <Divider style = { styles.divider } />
179 175
             <VolumeSlider
180
-                initialValue = { participantsVolume }
181
-                onChange = { onVolumeChange } />
176
+                initialValue = { initialParticipantsVolume } />
182 177
         </BottomSheet>
183 178
     );
184 179
 };

+ 4
- 5
react/features/participants-pane/components/native/LobbyParticipantList.js Ver fichero

@@ -10,13 +10,12 @@ import { admitMultiple } from '../../../lobby/actions.native';
10 10
 import { getLobbyState } from '../../../lobby/functions';
11 11
 
12 12
 import { LobbyParticipantItem } from './LobbyParticipantItem';
13
-import { participants } from './participants';
14 13
 import styles from './styles';
15 14
 
16 15
 export const LobbyParticipantList = () => {
17 16
     const {
18 17
         lobbyEnabled,
19
-        knockingParticipants
18
+        knockingParticipants: participants
20 19
     } = useSelector(getLobbyState);
21 20
 
22 21
     const dispatch = useDispatch();
@@ -25,9 +24,9 @@ export const LobbyParticipantList = () => {
25 24
         [ dispatch ]);
26 25
     const { t } = useTranslation();
27 26
 
28
-    // if (!lobbyEnabled || !participants.length) {
29
-    //     return null;
30
-    // }
27
+    if (!lobbyEnabled || !participants.length) {
28
+        return null;
29
+    }
31 30
 
32 31
     return (
33 32
         <View style = { styles.lobbyList }>

+ 8
- 12
react/features/video-menu/components/native/VolumeSlider.js Ver fichero

@@ -1,6 +1,7 @@
1 1
 // @flow
2 2
 
3 3
 import Slider from '@react-native-community/slider';
4
+import _ from 'lodash';
4 5
 import React, { Component } from 'react';
5 6
 import { View } from 'react-native';
6 7
 import { withTheme } from 'react-native-paper';
@@ -20,11 +21,6 @@ type Props = {
20 21
      */
21 22
     initialValue: number,
22 23
 
23
-    /**
24
-     * The callback to invoke when the audio slider value changes.
25
-     */
26
-    onChange: Function,
27
-
28 24
     /**
29 25
      * Theme used for styles.
30 26
      */
@@ -49,6 +45,8 @@ type State = {
49 45
  * @returns {React$Element<any>}
50 46
  */
51 47
 class VolumeSlider extends Component<Props, State> {
48
+    _onVolumeChange: Function;
49
+    _originalVolumeChange: Function;
52 50
 
53 51
     /**
54 52
      * Initializes a new {@code VolumeSlider} instance.
@@ -63,8 +61,11 @@ class VolumeSlider extends Component<Props, State> {
63 61
             volumeLevel: (props.initialValue || 0) * VOLUME_SLIDER_SCALE
64 62
         };
65 63
 
66
-        // Bind event handlers so they are only bound once for every instance.
67
-        this._onVolumeChange = this._onVolumeChange.bind(this);
64
+        this._originalVolumeChange = this._onVolumeChange;
65
+
66
+        this._onVolumeChange = _.throttle(
67
+            volumeLevel => this._originalVolumeChange(volumeLevel), 500
68
+        );
68 69
     }
69 70
 
70 71
     /**
@@ -96,8 +97,6 @@ class VolumeSlider extends Component<Props, State> {
96 97
         );
97 98
     }
98 99
 
99
-    _onVolumeChange: (Object) => void;
100
-
101 100
     /**
102 101
      * Sets the internal state of the volume level for the volume slider.
103 102
      * Invokes the prop onVolumeChange to notify of volume changes.
@@ -107,9 +106,6 @@ class VolumeSlider extends Component<Props, State> {
107 106
      * @returns {void}
108 107
      */
109 108
     _onVolumeChange(volumeLevel) {
110
-        const { onChange } = this.props;
111
-
112
-        onChange(volumeLevel / VOLUME_SLIDER_SCALE);
113 109
         this.setState({ volumeLevel });
114 110
     }
115 111
 }

Loading…
Cancelar
Guardar