Przeglądaj źródła

feat(native-participants-pane) open/close pane native actions

master
Calin Chitu 4 lat temu
rodzic
commit
400f47963d

+ 26
- 0
react/features/participants-pane/actions.native.js Wyświetl plik

@@ -1,7 +1,33 @@
1 1
 import { openDialog } from '../base/dialog';
2 2
 
3
+import { PARTICIPANTS_PANE_CLOSE, PARTICIPANTS_PANE_OPEN } from './actionTypes';
3 4
 import { ContextMenuLobbyParticipantReject, ContextMenuMeetingParticipantDetails } from './components/native';
4 5
 
6
+
7
+/**
8
+ * Action to open the participants pane.
9
+ *
10
+ * @returns {Object}
11
+ */
12
+export function open() {
13
+    console.log(2);
14
+
15
+    return {
16
+        type: PARTICIPANTS_PANE_OPEN
17
+    };
18
+}
19
+
20
+/**
21
+ * Action to close the participants pane.
22
+ *
23
+ * @returns {Object}
24
+ */
25
+export function close() {
26
+    return {
27
+        type: PARTICIPANTS_PANE_CLOSE
28
+    };
29
+}
30
+
5 31
 /**
6 32
  * Displays the context menu for the selected lobby participant.
7 33
  *

+ 36
- 5
react/features/participants-pane/components/native/ParticipantsPane.js Wyświetl plik

@@ -4,26 +4,37 @@ import React, { useCallback } from 'react';
4 4
 import { useTranslation } from 'react-i18next';
5 5
 import { ScrollView, View } from 'react-native';
6 6
 import { Button } from 'react-native-paper';
7
-import { useDispatch, useSelector } from 'react-redux';
7
+import { useDispatch, useSelector, connect } from 'react-redux';
8 8
 
9 9
 import { hideDialog, openDialog } from '../../../base/dialog';
10 10
 import { Icon, IconClose, IconHorizontalPoints } from '../../../base/icons';
11 11
 import { JitsiModal } from '../../../base/modal';
12
-import { isLocalParticipantModerator } from '../../../base/participants';
12
+import {
13
+    isLocalParticipantModerator
14
+} from '../../../base/participants';
13 15
 import MuteEveryoneDialog
14 16
     from '../../../video-menu/components/native/MuteEveryoneDialog';
17
+import { PARTICIPANTS_PANE_ID } from '../../constants';
15 18
 
16 19
 import { ContextMenuMore } from './ContextMenuMore';
17 20
 import { LobbyParticipantList } from './LobbyParticipantList';
18 21
 import { MeetingParticipantList } from './MeetingParticipantList';
19 22
 import styles from './styles';
20 23
 
24
+type Props = {
25
+
26
+    /**
27
+     * Is the participants pane open
28
+     */
29
+    _isOpen: boolean
30
+};
31
+
21 32
 /**
22 33
  * Participant pane.
23 34
  *
24 35
  * @returns {React$Element<any>}
25 36
  */
26
-function ParticipantsPane() {
37
+function ParticipantsPane({ _isOpen: paneOpen }: Props) {
27 38
     const dispatch = useDispatch();
28 39
     const openMoreMenu = useCallback(() => dispatch(openDialog(ContextMenuMore)), [ dispatch ]);
29 40
     const closePane = useCallback(() => dispatch(hideDialog()), [ dispatch ]);
@@ -33,8 +44,10 @@ function ParticipantsPane() {
33 44
     const { t } = useTranslation();
34 45
 
35 46
     return (
36
-        <JitsiModal
47
+        paneOpen
48
+        && <JitsiModal
37 49
             hideHeaderWithNavigation = { true }
50
+            modalId = { PARTICIPANTS_PANE_ID }
38 51
             style = { styles.participantsPane }>
39 52
             <View style = { styles.header }>
40 53
                 <Button
@@ -80,5 +93,23 @@ function ParticipantsPane() {
80 93
     );
81 94
 }
82 95
 
96
+/**
97
+ * Maps (parts of) the redux state to {@link ParticipantsPane} React {@code Component}
98
+ * props.
99
+ *
100
+ * @param {Object} state - The redux store/state.
101
+ * @private
102
+ * @returns {{
103
+ *     _isOpen: boolean,
104
+ * }}
105
+ */
106
+function _mapStateToProps(state: Object) {
107
+    const { isOpen } = state['features/participants-pane'];
108
+
109
+    return {
110
+        _isOpen: isOpen
111
+    };
112
+}
113
+
83 114
 
84
-export default ParticipantsPane;
115
+export default connect(_mapStateToProps)(ParticipantsPane);

+ 2
- 4
react/features/participants-pane/components/native/ParticipantsPaneButton.js Wyświetl plik

@@ -2,13 +2,11 @@
2 2
 
3 3
 import type { Dispatch } from 'redux';
4 4
 
5
-import { openDialog } from '../../../base/dialog';
6 5
 import { translate } from '../../../base/i18n';
7 6
 import { IconParticipants } from '../../../base/icons';
8 7
 import { connect } from '../../../base/redux';
9 8
 import { AbstractButton, type AbstractButtonProps } from '../../../base/toolbox/components';
10
-
11
-import { ParticipantsPane } from './';
9
+import { open } from '../../actions.native';
12 10
 
13 11
 type Props = AbstractButtonProps & {
14 12
 
@@ -34,7 +32,7 @@ class ParticipantsPaneButton extends AbstractButton<Props, *> {
34 32
      * @returns {void}
35 33
      */
36 34
     _handleClick() {
37
-        this.props.dispatch(openDialog(ParticipantsPane));
35
+        this.props.dispatch(open());
38 36
     }
39 37
 }
40 38
 

+ 2
- 0
react/features/participants-pane/constants.js Wyświetl plik

@@ -1,5 +1,7 @@
1 1
 // @flow
2 2
 
3
+export const PARTICIPANTS_PANE_ID = 'participantsPane';
4
+
3 5
 /**
4 6
  * Reducer key for the feature.
5 7
  */

Ładowanie…
Anuluj
Zapisz