瀏覽代碼

fix(lobby) don't mix web and native actions on the same file

USe actions.any for common actions.
master
Saúl Ibarra Corretgé 4 年之前
父節點
當前提交
a6359e5d4c
共有 3 個文件被更改,包括 216 次插入211 次删除
  1. 194
    2
      react/features/lobby/actions.any.js
  2. 15
    1
      react/features/lobby/actions.native.js
  3. 7
    208
      react/features/lobby/actions.web.js

+ 194
- 2
react/features/lobby/actions.any.js 查看文件

@@ -3,10 +3,202 @@
3 3
 import { type Dispatch } from 'redux';
4 4
 
5 5
 import {
6
-    getCurrentConference
6
+    conferenceWillJoin,
7
+    getCurrentConference,
8
+    sendLocalParticipant,
9
+    setPassword
7 10
 } from '../base/conference';
11
+import { getLocalParticipant } from '../base/participants';
8 12
 
9
-import { SET_LOBBY_VISIBILITY } from './actionTypes';
13
+import {
14
+    KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED,
15
+    KNOCKING_PARTICIPANT_LEFT,
16
+    SET_KNOCKING_STATE,
17
+    SET_LOBBY_MODE_ENABLED,
18
+    SET_PASSWORD_JOIN_FAILED,
19
+    SET_LOBBY_VISIBILITY
20
+} from './actionTypes';
21
+
22
+/**
23
+ * Tries to join with a preset password.
24
+ *
25
+ * @param {string} password - The password to join with.
26
+ * @returns {Function}
27
+ */
28
+export function joinWithPassword(password: string) {
29
+    return async (dispatch: Dispatch<any>, getState: Function) => {
30
+        const conference = getCurrentConference(getState);
31
+
32
+        dispatch(setPassword(conference, conference.join, password));
33
+    };
34
+}
35
+
36
+/**
37
+ * Action to be dispatched when a knocking poarticipant leaves before any response.
38
+ *
39
+ * @param {string} id - The ID of the participant.
40
+ * @returns {{
41
+ *     id: string,
42
+ *     type: KNOCKING_PARTICIPANT_LEFT
43
+ * }}
44
+ */
45
+export function knockingParticipantLeft(id: string) {
46
+    return {
47
+        id,
48
+        type: KNOCKING_PARTICIPANT_LEFT
49
+    };
50
+}
51
+
52
+/**
53
+ * Action to be executed when a participant starts knocking or an already knocking participant gets updated.
54
+ *
55
+ * @param {Object} participant - The knocking participant.
56
+ * @returns {{
57
+ *     participant: Object,
58
+ *     type: KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED
59
+ * }}
60
+ */
61
+export function participantIsKnockingOrUpdated(participant: Object) {
62
+    return {
63
+        participant,
64
+        type: KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED
65
+    };
66
+}
67
+
68
+/**
69
+ * Approves (lets in) or rejects a knocking participant.
70
+ *
71
+ * @param {string} id - The id of the knocking participant.
72
+ * @param {boolean} approved - True if the participant is approved, false otherwise.
73
+ * @returns {Function}
74
+ */
75
+export function setKnockingParticipantApproval(id: string, approved: boolean) {
76
+    return async (dispatch: Dispatch<any>, getState: Function) => {
77
+        const conference = getCurrentConference(getState);
78
+
79
+        if (conference) {
80
+            if (approved) {
81
+                conference.lobbyApproveAccess(id);
82
+            } else {
83
+                conference.lobbyDenyAccess(id);
84
+            }
85
+        }
86
+    };
87
+}
88
+
89
+/**
90
+ * Action used to admit multiple participants in the conference.
91
+ *
92
+ * @param {Array<Object>} participants - A list of knocking participants.
93
+ * @returns {void}
94
+ */
95
+export function admitMultiple(participants: Array<Object>) {
96
+    return (dispatch: Function, getState: Function) => {
97
+        const conference = getCurrentConference(getState);
98
+
99
+        participants.forEach(p => {
100
+            conference.lobbyApproveAccess(p.id);
101
+        });
102
+    };
103
+}
104
+
105
+/**
106
+ * Approves the request of a knocking participant to join the meeting.
107
+ *
108
+ * @param {string} id - The id of the knocking participant.
109
+ * @returns {Function}
110
+ */
111
+export function approveKnockingParticipant(id: string) {
112
+    return (dispatch: Dispatch<any>, getState: Function) => {
113
+        const conference = getCurrentConference(getState);
114
+
115
+        conference && conference.lobbyApproveAccess(id);
116
+    };
117
+}
118
+
119
+/**
120
+ * Denies the request of a knocking participant to join the meeting.
121
+ *
122
+ * @param {string} id - The id of the knocking participant.
123
+ * @returns {Function}
124
+ */
125
+export function rejectKnockingParticipant(id: string) {
126
+    return (dispatch: Dispatch<any>, getState: Function) => {
127
+        const conference = getCurrentConference(getState);
128
+
129
+        conference && conference.lobbyDenyAccess(id);
130
+    };
131
+}
132
+
133
+/**
134
+ * Action to set the knocking state of the participant.
135
+ *
136
+ * @param {boolean} knocking - The new state.
137
+ * @returns {{
138
+ *     state: boolean,
139
+ *     type: SET_KNOCKING_STATE
140
+ * }}
141
+ */
142
+export function setKnockingState(knocking: boolean) {
143
+    return {
144
+        knocking,
145
+        type: SET_KNOCKING_STATE
146
+    };
147
+}
148
+
149
+/**
150
+ * Action to set the new state of the lobby mode.
151
+ *
152
+ * @param {boolean} enabled - The new state to set.
153
+ * @returns {{
154
+ *     enabled: boolean,
155
+ *     type: SET_LOBBY_MODE_ENABLED
156
+ * }}
157
+ */
158
+export function setLobbyModeEnabled(enabled: boolean) {
159
+    return {
160
+        enabled,
161
+        type: SET_LOBBY_MODE_ENABLED
162
+    };
163
+}
164
+
165
+/**
166
+ * Action to be dispatched when we failed to join with a password.
167
+ *
168
+ * @param {boolean} failed - True of recent password join failed.
169
+ * @returns {{
170
+ *     failed: boolean,
171
+ *     type: SET_PASSWORD_JOIN_FAILED
172
+ * }}
173
+ */
174
+export function setPasswordJoinFailed(failed: boolean) {
175
+    return {
176
+        failed,
177
+        type: SET_PASSWORD_JOIN_FAILED
178
+    };
179
+}
180
+
181
+/**
182
+ * Starts knocking and waiting for approval.
183
+ *
184
+ * @returns {Function}
185
+ */
186
+export function startKnocking() {
187
+    return async (dispatch: Dispatch<any>, getState: Function) => {
188
+        const state = getState();
189
+        const { membersOnly } = state['features/base/conference'];
190
+        const localParticipant = getLocalParticipant(state);
191
+
192
+        dispatch(conferenceWillJoin(membersOnly));
193
+
194
+        // We need to update the conference object with the current display name, if approved
195
+        // we want to send that display name, it was not updated in case when pre-join is disabled
196
+        sendLocalParticipant(state, membersOnly);
197
+
198
+        membersOnly.joinLobby(localParticipant.name, localParticipant.email);
199
+        dispatch(setKnockingState(true));
200
+    };
201
+}
10 202
 
11 203
 /**
12 204
  * Action to toggle lobby mode on or off.

+ 15
- 1
react/features/lobby/actions.native.js 查看文件

@@ -1,10 +1,24 @@
1 1
 // @flow
2 2
 
3
+import { type Dispatch } from 'redux';
4
+
5
+import { appNavigate } from '../app/actions';
3 6
 import { openDialog } from '../base/dialog';
4 7
 
5 8
 import { DisableLobbyModeDialog, EnableLobbyModeDialog } from './components/native';
6 9
 
7
-export * from './actions.web';
10
+export * from './actions.any';
11
+
12
+/**
13
+ * Cancels the ongoing knocking and abandons the join flow.
14
+ *
15
+ * @returns {Function}
16
+ */
17
+export function cancelKnocking() {
18
+    return async (dispatch: Dispatch<any>) => {
19
+        dispatch(appNavigate(undefined));
20
+    };
21
+}
8 22
 
9 23
 /**
10 24
  * Action to show the dialog to disable lobby mode.

+ 7
- 208
react/features/lobby/actions.web.js 查看文件

@@ -2,223 +2,22 @@
2 2
 
3 3
 import { type Dispatch } from 'redux';
4 4
 
5
-import { appNavigate, maybeRedirectToWelcomePage } from '../app/actions';
6
-import {
7
-    conferenceWillJoin,
8
-    getCurrentConference,
9
-    sendLocalParticipant,
10
-    setPassword
11
-} from '../base/conference';
12
-import { getLocalParticipant } from '../base/participants';
13
-export * from './actions.any';
5
+import { maybeRedirectToWelcomePage } from '../app/actions';
14 6
 
15
-import {
16
-    KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED,
17
-    KNOCKING_PARTICIPANT_LEFT,
18
-    SET_KNOCKING_STATE,
19
-    SET_LOBBY_MODE_ENABLED,
20
-    SET_PASSWORD_JOIN_FAILED
21
-} from './actionTypes';
7
+export * from './actions.any';
22 8
 
23 9
 declare var APP: Object;
24 10
 
25 11
 /**
26
- * Cancels the ongoing knocking and abandones the join flow.
12
+ * Cancels the ongoing knocking and abandons the join flow.
27 13
  *
28 14
  * @returns {Function}
29 15
  */
30 16
 export function cancelKnocking() {
31 17
     return async (dispatch: Dispatch<any>) => {
32
-        if (typeof APP !== 'undefined') {
33
-            // when we are redirecting the library should handle any
34
-            // unload and clean of the connection.
35
-            APP.API.notifyReadyToClose();
36
-            dispatch(maybeRedirectToWelcomePage());
37
-
38
-            return;
39
-        }
40
-
41
-        dispatch(appNavigate(undefined));
42
-    };
43
-}
44
-
45
-/**
46
- * Tries to join with a preset password.
47
- *
48
- * @param {string} password - The password to join with.
49
- * @returns {Function}
50
- */
51
-export function joinWithPassword(password: string) {
52
-    return async (dispatch: Dispatch<any>, getState: Function) => {
53
-        const conference = getCurrentConference(getState);
54
-
55
-        dispatch(setPassword(conference, conference.join, password));
56
-    };
57
-}
58
-
59
-/**
60
- * Action to be dispatched when a knocking poarticipant leaves before any response.
61
- *
62
- * @param {string} id - The ID of the participant.
63
- * @returns {{
64
- *     id: string,
65
- *     type: KNOCKING_PARTICIPANT_LEFT
66
- * }}
67
- */
68
-export function knockingParticipantLeft(id: string) {
69
-    return {
70
-        id,
71
-        type: KNOCKING_PARTICIPANT_LEFT
72
-    };
73
-}
74
-
75
-/**
76
- * Action to be executed when a participant starts knocking or an already knocking participant gets updated.
77
- *
78
- * @param {Object} participant - The knocking participant.
79
- * @returns {{
80
- *     participant: Object,
81
- *     type: KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED
82
- * }}
83
- */
84
-export function participantIsKnockingOrUpdated(participant: Object) {
85
-    return {
86
-        participant,
87
-        type: KNOCKING_PARTICIPANT_ARRIVED_OR_UPDATED
88
-    };
89
-}
90
-
91
-/**
92
- * Approves (lets in) or rejects a knocking participant.
93
- *
94
- * @param {string} id - The id of the knocking participant.
95
- * @param {boolean} approved - True if the participant is approved, false otherwise.
96
- * @returns {Function}
97
- */
98
-export function setKnockingParticipantApproval(id: string, approved: boolean) {
99
-    return async (dispatch: Dispatch<any>, getState: Function) => {
100
-        const conference = getCurrentConference(getState);
101
-
102
-        if (conference) {
103
-            if (approved) {
104
-                conference.lobbyApproveAccess(id);
105
-            } else {
106
-                conference.lobbyDenyAccess(id);
107
-            }
108
-        }
109
-    };
110
-}
111
-
112
-/**
113
- * Action used to admit multiple participants in the conference.
114
- *
115
- * @param {Array<Object>} participants - A list of knocking participants.
116
- * @returns {void}
117
- */
118
-export function admitMultiple(participants: Array<Object>) {
119
-    return (dispatch: Function, getState: Function) => {
120
-        const conference = getCurrentConference(getState);
121
-
122
-        participants.forEach(p => {
123
-            conference.lobbyApproveAccess(p.id);
124
-        });
125
-    };
126
-}
127
-
128
-/**
129
- * Approves the request of a knocking participant to join the meeting.
130
- *
131
- * @param {string} id - The id of the knocking participant.
132
- * @returns {Function}
133
- */
134
-export function approveKnockingParticipant(id: string) {
135
-    return (dispatch: Dispatch<any>, getState: Function) => {
136
-        const conference = getCurrentConference(getState);
137
-
138
-        conference && conference.lobbyApproveAccess(id);
139
-    };
140
-}
141
-
142
-/**
143
- * Denies the request of a knocking participant to join the meeting.
144
- *
145
- * @param {string} id - The id of the knocking participant.
146
- * @returns {Function}
147
- */
148
-export function rejectKnockingParticipant(id: string) {
149
-    return (dispatch: Dispatch<any>, getState: Function) => {
150
-        const conference = getCurrentConference(getState);
151
-
152
-        conference && conference.lobbyDenyAccess(id);
153
-    };
154
-}
155
-
156
-/**
157
- * Action to set the knocking state of the participant.
158
- *
159
- * @param {boolean} knocking - The new state.
160
- * @returns {{
161
- *     state: boolean,
162
- *     type: SET_KNOCKING_STATE
163
- * }}
164
- */
165
-export function setKnockingState(knocking: boolean) {
166
-    return {
167
-        knocking,
168
-        type: SET_KNOCKING_STATE
169
-    };
170
-}
171
-
172
-/**
173
- * Action to set the new state of the lobby mode.
174
- *
175
- * @param {boolean} enabled - The new state to set.
176
- * @returns {{
177
- *     enabled: boolean,
178
- *     type: SET_LOBBY_MODE_ENABLED
179
- * }}
180
- */
181
-export function setLobbyModeEnabled(enabled: boolean) {
182
-    return {
183
-        enabled,
184
-        type: SET_LOBBY_MODE_ENABLED
185
-    };
186
-}
187
-
188
-/**
189
- * Action to be dispatched when we failed to join with a password.
190
- *
191
- * @param {boolean} failed - True of recent password join failed.
192
- * @returns {{
193
- *     failed: boolean,
194
- *     type: SET_PASSWORD_JOIN_FAILED
195
- * }}
196
- */
197
-export function setPasswordJoinFailed(failed: boolean) {
198
-    return {
199
-        failed,
200
-        type: SET_PASSWORD_JOIN_FAILED
201
-    };
202
-}
203
-
204
-/**
205
- * Starts knocking and waiting for approval.
206
- *
207
- * @returns {Function}
208
- */
209
-export function startKnocking() {
210
-    return async (dispatch: Dispatch<any>, getState: Function) => {
211
-        const state = getState();
212
-        const { membersOnly } = state['features/base/conference'];
213
-        const localParticipant = getLocalParticipant(state);
214
-
215
-        dispatch(conferenceWillJoin(membersOnly));
216
-
217
-        // We need to update the conference object with the current display name, if approved
218
-        // we want to send that display name, it was not updated in case when pre-join is disabled
219
-        sendLocalParticipant(state, membersOnly);
220
-
221
-        membersOnly.joinLobby(localParticipant.name, localParticipant.email);
222
-        dispatch(setKnockingState(true));
18
+        // when we are redirecting the library should handle any
19
+        // unload and clean of the connection.
20
+        APP.API.notifyReadyToClose();
21
+        dispatch(maybeRedirectToWelcomePage());
223 22
     };
224 23
 }

Loading…
取消
儲存