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

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