Selaa lähdekoodia

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

master
Calin Chitu 3 vuotta sitten
vanhempi
commit
53d0a892b5

+ 0
- 9
react/features/filmstrip/functions.native.js Näytä tiedosto

26
     return getParticipantCountWithFake(state) > 1;
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 Näytä tiedosto

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

+ 4
- 5
react/features/participants-pane/components/native/LobbyParticipantList.js Näytä tiedosto

10
 import { getLobbyState } from '../../../lobby/functions';
10
 import { getLobbyState } from '../../../lobby/functions';
11
 
11
 
12
 import { LobbyParticipantItem } from './LobbyParticipantItem';
12
 import { LobbyParticipantItem } from './LobbyParticipantItem';
13
-import { participants } from './participants';
14
 import styles from './styles';
13
 import styles from './styles';
15
 
14
 
16
 export const LobbyParticipantList = () => {
15
 export const LobbyParticipantList = () => {
17
     const {
16
     const {
18
         lobbyEnabled,
17
         lobbyEnabled,
19
-        knockingParticipants
18
+        knockingParticipants: participants
20
     } = useSelector(getLobbyState);
19
     } = useSelector(getLobbyState);
21
 
20
 
22
     const dispatch = useDispatch();
21
     const dispatch = useDispatch();
25
         [ dispatch ]);
24
         [ dispatch ]);
26
     const { t } = useTranslation();
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
     return (
31
     return (
33
         <View style = { styles.lobbyList }>
32
         <View style = { styles.lobbyList }>

+ 8
- 12
react/features/video-menu/components/native/VolumeSlider.js Näytä tiedosto

1
 // @flow
1
 // @flow
2
 
2
 
3
 import Slider from '@react-native-community/slider';
3
 import Slider from '@react-native-community/slider';
4
+import _ from 'lodash';
4
 import React, { Component } from 'react';
5
 import React, { Component } from 'react';
5
 import { View } from 'react-native';
6
 import { View } from 'react-native';
6
 import { withTheme } from 'react-native-paper';
7
 import { withTheme } from 'react-native-paper';
20
      */
21
      */
21
     initialValue: number,
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
      * Theme used for styles.
25
      * Theme used for styles.
30
      */
26
      */
49
  * @returns {React$Element<any>}
45
  * @returns {React$Element<any>}
50
  */
46
  */
51
 class VolumeSlider extends Component<Props, State> {
47
 class VolumeSlider extends Component<Props, State> {
48
+    _onVolumeChange: Function;
49
+    _originalVolumeChange: Function;
52
 
50
 
53
     /**
51
     /**
54
      * Initializes a new {@code VolumeSlider} instance.
52
      * Initializes a new {@code VolumeSlider} instance.
63
             volumeLevel: (props.initialValue || 0) * VOLUME_SLIDER_SCALE
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
         );
97
         );
97
     }
98
     }
98
 
99
 
99
-    _onVolumeChange: (Object) => void;
100
-
101
     /**
100
     /**
102
      * Sets the internal state of the volume level for the volume slider.
101
      * Sets the internal state of the volume level for the volume slider.
103
      * Invokes the prop onVolumeChange to notify of volume changes.
102
      * Invokes the prop onVolumeChange to notify of volume changes.
107
      * @returns {void}
106
      * @returns {void}
108
      */
107
      */
109
     _onVolumeChange(volumeLevel) {
108
     _onVolumeChange(volumeLevel) {
110
-        const { onChange } = this.props;
111
-
112
-        onChange(volumeLevel / VOLUME_SLIDER_SCALE);
113
         this.setState({ volumeLevel });
109
         this.setState({ volumeLevel });
114
     }
110
     }
115
 }
111
 }

Loading…
Peruuta
Tallenna