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.

actions.js 21KB

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