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

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