You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. // @flow
  2. import type { Dispatch } from 'redux';
  3. import {
  4. createStartMutedConfigurationEvent,
  5. sendAnalytics
  6. } from '../../analytics';
  7. import { endpointMessageReceived } from '../../subtitles';
  8. import { getReplaceParticipant } from '../config/functions';
  9. import { JITSI_CONNECTION_CONFERENCE_KEY } from '../connection';
  10. import { JitsiConferenceEvents } from '../lib-jitsi-meet';
  11. import {
  12. MEDIA_TYPE,
  13. setAudioMuted,
  14. setAudioUnmutePermissions,
  15. setVideoMuted,
  16. setVideoUnmutePermissions
  17. } from '../media';
  18. import {
  19. dominantSpeakerChanged,
  20. getNormalizedDisplayName,
  21. participantConnectionStatusChanged,
  22. participantKicked,
  23. participantMutedUs,
  24. participantPresenceChanged,
  25. participantRoleChanged,
  26. participantUpdated
  27. } from '../participants';
  28. import {
  29. destroyLocalTracks,
  30. getLocalTracks,
  31. replaceLocalTrack,
  32. trackAdded,
  33. trackRemoved
  34. } from '../tracks';
  35. import { getBackendSafeRoomName } from '../util';
  36. import {
  37. AUTH_STATUS_CHANGED,
  38. CONFERENCE_FAILED,
  39. CONFERENCE_JOINED,
  40. CONFERENCE_LEFT,
  41. CONFERENCE_LOCAL_SUBJECT_CHANGED,
  42. CONFERENCE_SUBJECT_CHANGED,
  43. CONFERENCE_TIMESTAMP_CHANGED,
  44. CONFERENCE_UNIQUE_ID_SET,
  45. CONFERENCE_WILL_JOIN,
  46. CONFERENCE_WILL_LEAVE,
  47. DATA_CHANNEL_OPENED,
  48. KICKED_OUT,
  49. LOCK_STATE_CHANGED,
  50. NON_PARTICIPANT_MESSAGE_RECEIVED,
  51. P2P_STATUS_CHANGED,
  52. SEND_TONES,
  53. SET_FOLLOW_ME,
  54. SET_PASSWORD,
  55. SET_PASSWORD_FAILED,
  56. SET_ROOM,
  57. SET_PENDING_SUBJECT_CHANGE,
  58. SET_START_MUTED_POLICY,
  59. SET_START_REACTIONS_MUTED
  60. } from './actionTypes';
  61. import {
  62. AVATAR_URL_COMMAND,
  63. EMAIL_COMMAND,
  64. JITSI_CONFERENCE_URL_KEY
  65. } from './constants';
  66. import {
  67. _addLocalTracksToConference,
  68. commonUserJoinedHandling,
  69. commonUserLeftHandling,
  70. getConferenceOptions,
  71. getCurrentConference,
  72. sendLocalParticipant
  73. } from './functions';
  74. import logger from './logger';
  75. declare var APP: Object;
  76. /**
  77. * Adds conference (event) listeners.
  78. *
  79. * @param {JitsiConference} conference - The JitsiConference instance.
  80. * @param {Dispatch} dispatch - The Redux dispatch function.
  81. * @param {Object} state - The Redux state.
  82. * @private
  83. * @returns {void}
  84. */
  85. function _addConferenceListeners(conference, dispatch, state) {
  86. // A simple logger for conference errors received through
  87. // the listener. These errors are not handled now, but logged.
  88. conference.on(JitsiConferenceEvents.CONFERENCE_ERROR,
  89. error => logger.error('Conference error.', error));
  90. // Dispatches into features/base/conference follow:
  91. conference.on(
  92. JitsiConferenceEvents.AUTH_STATUS_CHANGED,
  93. (authEnabled, authLogin) => dispatch(authStatusChanged(authEnabled, authLogin)));
  94. conference.on(
  95. JitsiConferenceEvents.CONFERENCE_FAILED,
  96. (...args) => dispatch(conferenceFailed(conference, ...args)));
  97. conference.on(
  98. JitsiConferenceEvents.CONFERENCE_JOINED,
  99. (...args) => dispatch(conferenceJoined(conference, ...args)));
  100. conference.on(
  101. JitsiConferenceEvents.CONFERENCE_LEFT,
  102. (...args) => {
  103. dispatch(conferenceTimestampChanged(0));
  104. dispatch(conferenceLeft(conference, ...args));
  105. });
  106. conference.on(JitsiConferenceEvents.SUBJECT_CHANGED,
  107. (...args) => dispatch(conferenceSubjectChanged(...args)));
  108. conference.on(JitsiConferenceEvents.CONFERENCE_CREATED_TIMESTAMP,
  109. (...args) => dispatch(conferenceTimestampChanged(...args)));
  110. conference.on(
  111. JitsiConferenceEvents.KICKED,
  112. (...args) => dispatch(kickedOut(conference, ...args)));
  113. conference.on(
  114. JitsiConferenceEvents.PARTICIPANT_KICKED,
  115. (kicker, kicked) => dispatch(participantKicked(kicker, kicked)));
  116. conference.on(
  117. JitsiConferenceEvents.LOCK_STATE_CHANGED,
  118. (...args) => dispatch(lockStateChanged(conference, ...args)));
  119. // Dispatches into features/base/media follow:
  120. conference.on(
  121. JitsiConferenceEvents.STARTED_MUTED,
  122. () => {
  123. const audioMuted = Boolean(conference.isStartAudioMuted());
  124. const videoMuted = Boolean(conference.isStartVideoMuted());
  125. const localTracks = getLocalTracks(state['features/base/tracks']);
  126. sendAnalytics(createStartMutedConfigurationEvent('remote', audioMuted, videoMuted));
  127. logger.log(`Start muted: ${audioMuted ? 'audio, ' : ''}${videoMuted ? 'video' : ''}`);
  128. // XXX Jicofo tells lib-jitsi-meet to start with audio and/or video
  129. // muted i.e. Jicofo expresses an intent. Lib-jitsi-meet has turned
  130. // Jicofo's intent into reality by actually muting the respective
  131. // tracks. The reality is expressed in base/tracks already so what
  132. // is left is to express Jicofo's intent in base/media.
  133. // TODO Maybe the app needs to learn about Jicofo's intent and
  134. // transfer that intent to lib-jitsi-meet instead of lib-jitsi-meet
  135. // acting on Jicofo's intent without the app's knowledge.
  136. dispatch(setAudioMuted(audioMuted));
  137. dispatch(setVideoMuted(videoMuted));
  138. // Remove the tracks from peerconnection as well.
  139. for (const track of localTracks) {
  140. const trackType = track.jitsiTrack.getType();
  141. // Do not remove the audio track on RN. Starting with iOS 15 it will fail to unmute otherwise.
  142. if ((audioMuted && trackType === MEDIA_TYPE.AUDIO && navigator.product !== 'ReactNative')
  143. || (videoMuted && trackType === MEDIA_TYPE.VIDEO)) {
  144. dispatch(replaceLocalTrack(track.jitsiTrack, null, conference));
  145. }
  146. }
  147. });
  148. conference.on(
  149. JitsiConferenceEvents.AUDIO_UNMUTE_PERMISSIONS_CHANGED,
  150. disableAudioMuteChange => {
  151. dispatch(setAudioUnmutePermissions(disableAudioMuteChange));
  152. });
  153. conference.on(
  154. JitsiConferenceEvents.VIDEO_UNMUTE_PERMISSIONS_CHANGED,
  155. disableVideoMuteChange => {
  156. dispatch(setVideoUnmutePermissions(disableVideoMuteChange));
  157. });
  158. // Dispatches into features/base/tracks follow:
  159. conference.on(
  160. JitsiConferenceEvents.TRACK_ADDED,
  161. t => t && !t.isLocal() && dispatch(trackAdded(t)));
  162. conference.on(
  163. JitsiConferenceEvents.TRACK_REMOVED,
  164. t => t && !t.isLocal() && dispatch(trackRemoved(t)));
  165. conference.on(
  166. JitsiConferenceEvents.TRACK_MUTE_CHANGED,
  167. (track, participantThatMutedUs) => {
  168. if (participantThatMutedUs) {
  169. dispatch(participantMutedUs(participantThatMutedUs, track));
  170. }
  171. });
  172. conference.on(JitsiConferenceEvents.TRACK_UNMUTE_REJECTED, track => dispatch(destroyLocalTracks(track)));
  173. // Dispatches into features/base/participants follow:
  174. conference.on(
  175. JitsiConferenceEvents.DISPLAY_NAME_CHANGED,
  176. (id, displayName) => dispatch(participantUpdated({
  177. conference,
  178. id,
  179. name: getNormalizedDisplayName(displayName)
  180. })));
  181. conference.on(
  182. JitsiConferenceEvents.DOMINANT_SPEAKER_CHANGED,
  183. (dominant, previous) => dispatch(dominantSpeakerChanged(dominant, previous, conference)));
  184. conference.on(
  185. JitsiConferenceEvents.ENDPOINT_MESSAGE_RECEIVED,
  186. (...args) => dispatch(endpointMessageReceived(...args)));
  187. conference.on(
  188. JitsiConferenceEvents.NON_PARTICIPANT_MESSAGE_RECEIVED,
  189. (...args) => dispatch(nonParticipantMessageReceived(...args)));
  190. conference.on(
  191. JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
  192. (...args) => dispatch(participantConnectionStatusChanged(...args)));
  193. conference.on(
  194. JitsiConferenceEvents.USER_JOINED,
  195. (id, user) => commonUserJoinedHandling({ dispatch }, conference, user));
  196. conference.on(
  197. JitsiConferenceEvents.USER_LEFT,
  198. (id, user) => commonUserLeftHandling({ dispatch }, conference, user));
  199. conference.on(
  200. JitsiConferenceEvents.USER_ROLE_CHANGED,
  201. (...args) => dispatch(participantRoleChanged(...args)));
  202. conference.on(
  203. JitsiConferenceEvents.USER_STATUS_CHANGED,
  204. (...args) => dispatch(participantPresenceChanged(...args)));
  205. conference.on(
  206. JitsiConferenceEvents.BOT_TYPE_CHANGED,
  207. (id, botType) => dispatch(participantUpdated({
  208. conference,
  209. id,
  210. botType
  211. })));
  212. conference.addCommandListener(
  213. AVATAR_URL_COMMAND,
  214. (data, id) => dispatch(participantUpdated({
  215. conference,
  216. id,
  217. avatarURL: data.value
  218. })));
  219. conference.addCommandListener(
  220. EMAIL_COMMAND,
  221. (data, id) => dispatch(participantUpdated({
  222. conference,
  223. id,
  224. email: data.value
  225. })));
  226. }
  227. /**
  228. * Updates the current known state of server-side authentication.
  229. *
  230. * @param {boolean} authEnabled - Whether or not server authentication is
  231. * enabled.
  232. * @param {string} authLogin - The current name of the logged in user, if any.
  233. * @returns {{
  234. * type: AUTH_STATUS_CHANGED,
  235. * authEnabled: boolean,
  236. * authLogin: string
  237. * }}
  238. */
  239. export function authStatusChanged(authEnabled: boolean, authLogin: string) {
  240. return {
  241. type: AUTH_STATUS_CHANGED,
  242. authEnabled,
  243. authLogin
  244. };
  245. }
  246. /**
  247. * Signals that a specific conference has failed.
  248. *
  249. * @param {JitsiConference} conference - The JitsiConference that has failed.
  250. * @param {string} error - The error describing/detailing the cause of the
  251. * failure.
  252. * @param {any} params - Rest of the params that we receive together with the event.
  253. * @returns {{
  254. * type: CONFERENCE_FAILED,
  255. * conference: JitsiConference,
  256. * error: Error
  257. * }}
  258. * @public
  259. */
  260. export function conferenceFailed(conference: Object, error: string, ...params: any) {
  261. return {
  262. type: CONFERENCE_FAILED,
  263. conference,
  264. // Make the error resemble an Error instance (to the extent that
  265. // jitsi-meet needs it).
  266. error: {
  267. name: error,
  268. params,
  269. recoverable: undefined
  270. }
  271. };
  272. }
  273. /**
  274. * Signals that a specific conference has been joined.
  275. *
  276. * @param {JitsiConference} conference - The JitsiConference instance which was
  277. * joined by the local participant.
  278. * @returns {{
  279. * type: CONFERENCE_JOINED,
  280. * conference: JitsiConference
  281. * }}
  282. */
  283. export function conferenceJoined(conference: Object) {
  284. return {
  285. type: CONFERENCE_JOINED,
  286. conference
  287. };
  288. }
  289. /**
  290. * Signals that a specific conference has been left.
  291. *
  292. * @param {JitsiConference} conference - The JitsiConference instance which was
  293. * left by the local participant.
  294. * @returns {{
  295. * type: CONFERENCE_LEFT,
  296. * conference: JitsiConference
  297. * }}
  298. */
  299. export function conferenceLeft(conference: Object) {
  300. return {
  301. type: CONFERENCE_LEFT,
  302. conference
  303. };
  304. }
  305. /**
  306. * Signals that the conference subject has been changed.
  307. *
  308. * @param {string} subject - The new subject.
  309. * @returns {{
  310. * type: CONFERENCE_SUBJECT_CHANGED,
  311. * subject: string
  312. * }}
  313. */
  314. export function conferenceSubjectChanged(subject: string) {
  315. return {
  316. type: CONFERENCE_SUBJECT_CHANGED,
  317. subject
  318. };
  319. }
  320. /**
  321. * Signals that the conference timestamp has been changed.
  322. *
  323. * @param {number} conferenceTimestamp - The UTC timestamp.
  324. * @returns {{
  325. * type: CONFERENCE_TIMESTAMP_CHANGED,
  326. * conferenceTimestamp
  327. * }}
  328. */
  329. export function conferenceTimestampChanged(conferenceTimestamp: number) {
  330. return {
  331. type: CONFERENCE_TIMESTAMP_CHANGED,
  332. conferenceTimestamp
  333. };
  334. }
  335. /**
  336. * Signals that the unique identifier for conference has been set.
  337. *
  338. * @param {JitsiConference} conference - The JitsiConference instance, where the uuid has been set.
  339. * @returns {{
  340. * type: CONFERENCE_UNIQUE_ID_SET,
  341. * conference: JitsiConference,
  342. * }}
  343. */
  344. export function conferenceUniqueIdSet(conference: Object) {
  345. return {
  346. type: CONFERENCE_UNIQUE_ID_SET,
  347. conference
  348. };
  349. }
  350. /**
  351. * Adds any existing local tracks to a specific conference before the conference
  352. * is joined. Then signals the intention of the application to have the local
  353. * participant join the specified conference.
  354. *
  355. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  356. * the local participant will (try to) join.
  357. * @returns {Function}
  358. */
  359. export function _conferenceWillJoin(conference: Object) {
  360. return (dispatch: Dispatch<any>, getState: Function) => {
  361. const localTracks
  362. = getLocalTracks(getState()['features/base/tracks'])
  363. .map(t => t.jitsiTrack);
  364. if (localTracks.length) {
  365. _addLocalTracksToConference(conference, localTracks);
  366. }
  367. dispatch(conferenceWillJoin(conference));
  368. };
  369. }
  370. /**
  371. * Signals the intention of the application to have the local participant
  372. * join the specified conference.
  373. *
  374. * @param {JitsiConference} conference - The {@code JitsiConference} instance
  375. * the local participant will (try to) join.
  376. * @returns {{
  377. * type: CONFERENCE_WILL_JOIN,
  378. * conference: JitsiConference
  379. * }}
  380. */
  381. export function conferenceWillJoin(conference: Object) {
  382. return {
  383. type: CONFERENCE_WILL_JOIN,
  384. conference
  385. };
  386. }
  387. /**
  388. * Signals the intention of the application to have the local participant leave
  389. * a specific conference. Similar in fashion to CONFERENCE_LEFT. Contrary to it
  390. * though, it's not guaranteed because CONFERENCE_LEFT may be triggered by
  391. * lib-jitsi-meet and not the application.
  392. *
  393. * @param {JitsiConference} conference - The JitsiConference instance which will
  394. * be left by the local participant.
  395. * @returns {{
  396. * type: CONFERENCE_LEFT,
  397. * conference: JitsiConference
  398. * }}
  399. */
  400. export function conferenceWillLeave(conference: Object) {
  401. return {
  402. type: CONFERENCE_WILL_LEAVE,
  403. conference
  404. };
  405. }
  406. /**
  407. * Initializes a new conference.
  408. *
  409. * @param {string} overrideRoom - Override the room to join, instead of taking it
  410. * from Redux.
  411. * @returns {Function}
  412. */
  413. export function createConference(overrideRoom?: string) {
  414. return (dispatch: Function, getState: Function) => {
  415. const state = getState();
  416. const { connection, locationURL } = state['features/base/connection'];
  417. if (!connection) {
  418. throw new Error('Cannot create a conference without a connection!');
  419. }
  420. const { password, room } = state['features/base/conference'];
  421. if (!room) {
  422. throw new Error('Cannot join a conference without a room name!');
  423. }
  424. // XXX: revisit this.
  425. // Hide the custom domain in the room name.
  426. const tmp = overrideRoom || room;
  427. let _room = getBackendSafeRoomName(tmp);
  428. if (tmp.domain) {
  429. // eslint-disable-next-line no-new-wrappers
  430. _room = new String(tmp);
  431. // $FlowExpectedError
  432. _room.domain = tmp.domain;
  433. }
  434. const conference = connection.initJitsiConference(_room, getConferenceOptions(state));
  435. connection[JITSI_CONNECTION_CONFERENCE_KEY] = conference;
  436. conference[JITSI_CONFERENCE_URL_KEY] = locationURL;
  437. dispatch(_conferenceWillJoin(conference));
  438. _addConferenceListeners(conference, dispatch, state);
  439. sendLocalParticipant(state, conference);
  440. const replaceParticipant = getReplaceParticipant(state);
  441. conference.join(password, replaceParticipant);
  442. };
  443. }
  444. /**
  445. * Will try to join the conference again in case it failed earlier with
  446. * {@link JitsiConferenceErrors.AUTHENTICATION_REQUIRED}. It means that Jicofo
  447. * did not allow to create new room from anonymous domain, but it can be tried
  448. * again later in case authenticated user created it in the meantime.
  449. *
  450. * @returns {Function}
  451. */
  452. export function checkIfCanJoin() {
  453. return (dispatch: Function, getState: Function) => {
  454. const { authRequired, password }
  455. = getState()['features/base/conference'];
  456. const replaceParticipant = getReplaceParticipant(getState());
  457. authRequired && dispatch(_conferenceWillJoin(authRequired));
  458. authRequired && authRequired.join(password, replaceParticipant);
  459. };
  460. }
  461. /**
  462. * Signals the data channel with the bridge has successfully opened.
  463. *
  464. * @returns {{
  465. * type: DATA_CHANNEL_OPENED
  466. * }}
  467. */
  468. export function dataChannelOpened() {
  469. return {
  470. type: DATA_CHANNEL_OPENED
  471. };
  472. }
  473. /**
  474. * Signals that we've been kicked out of the conference.
  475. *
  476. * @param {JitsiConference} conference - The {@link JitsiConference} instance
  477. * for which the event is being signaled.
  478. * @param {JitsiParticipant} participant - The {@link JitsiParticipant}
  479. * instance which initiated the kick event.
  480. * @returns {{
  481. * type: KICKED_OUT,
  482. * conference: JitsiConference,
  483. * participant: JitsiParticipant
  484. * }}
  485. */
  486. export function kickedOut(conference: Object, participant: Object) {
  487. return {
  488. type: KICKED_OUT,
  489. conference,
  490. participant
  491. };
  492. }
  493. /**
  494. * Signals that the lock state of a specific JitsiConference changed.
  495. *
  496. * @param {JitsiConference} conference - The JitsiConference which had its lock
  497. * state changed.
  498. * @param {boolean} locked - If the specified conference became locked, true;
  499. * otherwise, false.
  500. * @returns {{
  501. * type: LOCK_STATE_CHANGED,
  502. * conference: JitsiConference,
  503. * locked: boolean
  504. * }}
  505. */
  506. export function lockStateChanged(conference: Object, locked: boolean) {
  507. return {
  508. type: LOCK_STATE_CHANGED,
  509. conference,
  510. locked
  511. };
  512. }
  513. /**
  514. * Signals that a non participant endpoint message has been received.
  515. *
  516. * @param {string} id - The resource id of the sender.
  517. * @param {Object} json - The json carried by the endpoint message.
  518. * @returns {{
  519. * type: NON_PARTICIPANT_MESSAGE_RECEIVED,
  520. * id: Object,
  521. * json: Object
  522. * }}
  523. */
  524. export function nonParticipantMessageReceived(id: String, json: Object) {
  525. return {
  526. type: NON_PARTICIPANT_MESSAGE_RECEIVED,
  527. id,
  528. json
  529. };
  530. }
  531. /**
  532. * Updates the known state of start muted policies.
  533. *
  534. * @param {boolean} audioMuted - Whether or not members will join the conference
  535. * as audio muted.
  536. * @param {boolean} videoMuted - Whether or not members will join the conference
  537. * as video muted.
  538. * @returns {{
  539. * type: SET_START_MUTED_POLICY,
  540. * startAudioMutedPolicy: boolean,
  541. * startVideoMutedPolicy: boolean
  542. * }}
  543. */
  544. export function onStartMutedPolicyChanged(
  545. audioMuted: boolean, videoMuted: boolean) {
  546. return {
  547. type: SET_START_MUTED_POLICY,
  548. startAudioMutedPolicy: audioMuted,
  549. startVideoMutedPolicy: videoMuted
  550. };
  551. }
  552. /**
  553. * Sets whether or not peer2peer is currently enabled.
  554. *
  555. * @param {boolean} p2p - Whether or not peer2peer is currently active.
  556. * @returns {{
  557. * type: P2P_STATUS_CHANGED,
  558. * p2p: boolean
  559. * }}
  560. */
  561. export function p2pStatusChanged(p2p: boolean) {
  562. return {
  563. type: P2P_STATUS_CHANGED,
  564. p2p
  565. };
  566. }
  567. /**
  568. * Signals to play touch tones.
  569. *
  570. * @param {string} tones - The tones to play.
  571. * @param {number} [duration] - How long to play each tone.
  572. * @param {number} [pause] - How long to pause between each tone.
  573. * @returns {{
  574. * type: SEND_TONES,
  575. * tones: string,
  576. * duration: number,
  577. * pause: number
  578. * }}
  579. */
  580. export function sendTones(tones: string, duration: number, pause: number) {
  581. return {
  582. type: SEND_TONES,
  583. tones,
  584. duration,
  585. pause
  586. };
  587. }
  588. /**
  589. * Enables or disables the Follow Me feature.
  590. *
  591. * @param {boolean} enabled - Whether or not Follow Me should be enabled.
  592. * @returns {{
  593. * type: SET_FOLLOW_ME,
  594. * enabled: boolean
  595. * }}
  596. */
  597. export function setFollowMe(enabled: boolean) {
  598. return {
  599. type: SET_FOLLOW_ME,
  600. enabled
  601. };
  602. }
  603. /**
  604. * Enables or disables the Mute reaction sounds feature.
  605. *
  606. * @param {boolean} muted - Whether or not reaction sounds should be muted for all participants.
  607. * @param {boolean} updateBackend - Whether or not the moderator should notify all participants for the new setting.
  608. * @returns {{
  609. * type: SET_START_REACTIONS_MUTED,
  610. * muted: boolean
  611. * }}
  612. */
  613. export function setStartReactionsMuted(muted: boolean, updateBackend: boolean = false) {
  614. return {
  615. type: SET_START_REACTIONS_MUTED,
  616. muted,
  617. updateBackend
  618. };
  619. }
  620. /**
  621. * Sets the password to join or lock a specific JitsiConference.
  622. *
  623. * @param {JitsiConference} conference - The JitsiConference which requires a
  624. * password to join or is to be locked with the specified password.
  625. * @param {Function} method - The JitsiConference method of password protection
  626. * such as join or lock.
  627. * @param {string} password - The password with which the specified conference
  628. * is to be joined or locked.
  629. * @returns {Function}
  630. */
  631. export function setPassword(
  632. conference: Object,
  633. method: Function,
  634. password: string) {
  635. return (dispatch: Dispatch<any>, getState: Function): ?Promise<void> => {
  636. switch (method) {
  637. case conference.join: {
  638. let state = getState()['features/base/conference'];
  639. dispatch({
  640. type: SET_PASSWORD,
  641. conference,
  642. method,
  643. password
  644. });
  645. // Join the conference with the newly-set password.
  646. // Make sure that the action did set the password.
  647. state = getState()['features/base/conference'];
  648. if (state.password === password
  649. // Make sure that the application still wants the
  650. // conference joined.
  651. && !state.conference) {
  652. method.call(conference, password);
  653. }
  654. break;
  655. }
  656. case conference.lock: {
  657. const state = getState()['features/base/conference'];
  658. if (state.conference === conference) {
  659. return (
  660. method.call(conference, password)
  661. .then(() => dispatch({
  662. type: SET_PASSWORD,
  663. conference,
  664. method,
  665. password
  666. }))
  667. .catch(error => dispatch({
  668. type: SET_PASSWORD_FAILED,
  669. error
  670. }))
  671. );
  672. }
  673. return Promise.reject();
  674. }
  675. }
  676. };
  677. }
  678. /**
  679. * Sets (the name of) the room of the conference to be joined.
  680. *
  681. * @param {(string|undefined)} room - The name of the room of the conference to
  682. * be joined.
  683. * @returns {{
  684. * type: SET_ROOM,
  685. * room: string
  686. * }}
  687. */
  688. export function setRoom(room: ?string) {
  689. return {
  690. type: SET_ROOM,
  691. room
  692. };
  693. }
  694. /**
  695. * Sets whether or not members should join audio and/or video muted.
  696. *
  697. * @param {boolean} startAudioMuted - Whether or not members will join the
  698. * conference as audio muted.
  699. * @param {boolean} startVideoMuted - Whether or not members will join the
  700. * conference as video muted.
  701. * @returns {Function}
  702. */
  703. export function setStartMutedPolicy(
  704. startAudioMuted: boolean, startVideoMuted: boolean) {
  705. return (dispatch: Dispatch<any>, getState: Function) => {
  706. const conference = getCurrentConference(getState());
  707. conference && conference.setStartMutedPolicy({
  708. audio: startAudioMuted,
  709. video: startVideoMuted
  710. });
  711. return dispatch(
  712. onStartMutedPolicyChanged(startAudioMuted, startVideoMuted));
  713. };
  714. }
  715. /**
  716. * Sets the conference subject.
  717. *
  718. * @param {string} subject - The new subject.
  719. * @returns {void}
  720. */
  721. export function setSubject(subject: string) {
  722. return (dispatch: Dispatch<any>, getState: Function) => {
  723. const { conference } = getState()['features/base/conference'];
  724. if (conference) {
  725. conference.setSubject(subject || '');
  726. } else {
  727. dispatch({
  728. type: SET_PENDING_SUBJECT_CHANGE,
  729. subject
  730. });
  731. }
  732. };
  733. }
  734. /**
  735. * Sets the conference local subject.
  736. *
  737. * @param {string} localSubject - The new local subject.
  738. * @returns {{
  739. * type: CONFERENCE_LOCAL_SUBJECT_CHANGED,
  740. * localSubject: string
  741. * }}
  742. */
  743. export function setLocalSubject(localSubject: string) {
  744. return {
  745. type: CONFERENCE_LOCAL_SUBJECT_CHANGED,
  746. localSubject
  747. };
  748. }