Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

actions.js 21KB

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