|
|
@@ -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
|
}
|