您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

actions.js 21KB

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