Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

actions.js 24KB

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