forked from jitsi/jitsi-meet
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathactions.web.ts
More file actions
114 lines (103 loc) · 4.2 KB
/
Copy pathactions.web.ts
File metadata and controls
114 lines (103 loc) · 4.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// @ts-expect-error
import { jitsiLocalStorage } from '@jitsi/js-utils';
import { IStore } from '../../app/types';
import { getCustomerDetails } from '../../jaas/actions.any';
import { getJaasJWT, isVpaasMeeting } from '../../jaas/functions';
import { showWarningNotification } from '../../notifications/actions';
import { NOTIFICATION_TIMEOUT_TYPE } from '../../notifications/constants';
import { stopLocalVideoRecording } from '../../recording/actions.any';
import LocalRecordingManager from '../../recording/components/Recording/LocalRecordingManager.web';
import { setJWT } from '../jwt/actions';
import { LocalStorageManager } from "../meet/LocalStorageManager";
import MeetingService from "../meet/services/meeting.service";
import { _connectInternal } from "./actions.any";
export * from "./actions.any";
/**
* Opens new connection.
*
* @param {string} [id] - The XMPP user's ID (e.g. {@code user@server.com}).
* @param {string} [password] - The XMPP user's password.
* @returns {Function}
*/
export function connect(id?: string, password?: string) {
return (dispatch: IStore["dispatch"], getState: IStore["getState"]) => {
const state = getState();
const { jwt } = state["features/base/jwt"];
const { iAmRecorder, iAmSipGateway } = state["features/base/config"];
// TODO: CHECK WHY USER REDUCER IS NULL IN THIS POINT, initializers are not executing as expected
// const { user } = state["features/user"];
const user = LocalStorageManager.instance.getUser();
if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {
return dispatch(getCustomerDetails())
.then(() => {
if (!jwt) {
return getJaasJWT(state);
}
})
.then((j) => j && dispatch(setJWT(j)))
.then(() =>
dispatch(
_connectInternal({
id,
password,
name: user?.name,
lastname: user?.lastname,
isAnonymous: !user,
})
)
);
}
// used by jibri
const usernameOverride = jitsiLocalStorage.getItem("xmpp_username_override");
const passwordOverride = jitsiLocalStorage.getItem("xmpp_password_override");
if (usernameOverride && usernameOverride.length > 0) {
id = usernameOverride; // eslint-disable-line no-param-reassign
}
if (passwordOverride && passwordOverride.length > 0) {
password = passwordOverride; // eslint-disable-line no-param-reassign
}
return dispatch(
_connectInternal({
id,
password,
name: user?.name,
lastname: user?.lastname,
isAnonymous: !user,
})
);
};
}
/**
* Closes connection.
*
* @param {boolean} [requestFeedback] - Whether to attempt showing a
* request for call feedback.
* @param {string} [feedbackTitle] - The feedback title.
* @returns {Function}
*/
export function hangup(requestFeedback = false, roomId?: string, feedbackTitle?: string) {
// XXX For web based version we use conference hanging up logic from the old app.
return async (dispatch: IStore["dispatch"]) => {
if (LocalRecordingManager.isRecordingLocally()) {
dispatch(stopLocalVideoRecording());
dispatch(
showWarningNotification(
{
titleKey: "localRecording.stopping",
descriptionKey: "localRecording.wait",
},
NOTIFICATION_TIMEOUT_TYPE.STICKY
)
);
// wait 1000ms for the recording to end and start downloading
await new Promise((res) => {
setTimeout(res, 1000);
});
}
if (!roomId) {
return Promise.reject(new Error("No roomId provided to hangup"));
}
MeetingService.instance.leaveCall(roomId);
return APP.conference.hangup(requestFeedback, feedbackTitle);
};
}