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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. import { AnyAction } from 'redux';
  2. import { FaceLandmarks } from '../../face-landmarks/types';
  3. import { LOCKED_LOCALLY, LOCKED_REMOTELY } from '../../room-lock/constants';
  4. import { ISpeakerStats } from '../../speaker-stats/reducer';
  5. import { SET_CONFIG } from '../config/actionTypes';
  6. import { IConfig } from '../config/configType';
  7. import { CONNECTION_WILL_CONNECT, SET_LOCATION_URL } from '../connection/actionTypes';
  8. import { JitsiConferenceErrors } from '../lib-jitsi-meet';
  9. import ReducerRegistry from '../redux/ReducerRegistry';
  10. import { assign, equals, set } from '../redux/functions';
  11. import {
  12. AUTH_STATUS_CHANGED,
  13. CONFERENCE_FAILED,
  14. CONFERENCE_JOINED,
  15. CONFERENCE_LEFT,
  16. CONFERENCE_LOCAL_SUBJECT_CHANGED,
  17. CONFERENCE_PROPERTIES_CHANGED,
  18. CONFERENCE_SUBJECT_CHANGED,
  19. CONFERENCE_TIMESTAMP_CHANGED,
  20. CONFERENCE_WILL_JOIN,
  21. CONFERENCE_WILL_LEAVE,
  22. DATA_CHANNEL_CLOSED,
  23. DATA_CHANNEL_OPENED,
  24. LOCK_STATE_CHANGED,
  25. P2P_STATUS_CHANGED,
  26. SET_ASSUMED_BANDWIDTH_BPS,
  27. SET_FOLLOW_ME,
  28. SET_FOLLOW_ME_RECORDER,
  29. SET_OBFUSCATED_ROOM,
  30. SET_PASSWORD,
  31. SET_PENDING_SUBJECT_CHANGE,
  32. SET_ROOM,
  33. SET_START_MUTED_POLICY,
  34. SET_START_REACTIONS_MUTED,
  35. UPDATE_CONFERENCE_METADATA
  36. } from './actionTypes';
  37. import { isRoomValid } from './functions';
  38. const DEFAULT_STATE = {
  39. assumedBandwidthBps: undefined,
  40. conference: undefined,
  41. dataChannelOpen: undefined,
  42. e2eeSupported: undefined,
  43. joining: undefined,
  44. leaving: undefined,
  45. locked: undefined,
  46. membersOnly: undefined,
  47. metadata: undefined,
  48. password: undefined,
  49. passwordRequired: undefined,
  50. properties: undefined
  51. };
  52. export interface IConferenceMetadata {
  53. recording?: {
  54. isTranscribingEnabled: boolean;
  55. };
  56. visitors?: {
  57. live: boolean;
  58. };
  59. whiteboard?: {
  60. collabDetails: {
  61. roomId: string;
  62. roomKey: string;
  63. };
  64. };
  65. }
  66. export interface IJitsiConference {
  67. addCommandListener: Function;
  68. addLobbyMessageListener: Function;
  69. addTrack: Function;
  70. authenticateAndUpgradeRole: Function;
  71. avModerationApprove: Function;
  72. avModerationReject: Function;
  73. callUUID?: string;
  74. createVideoSIPGWSession: Function;
  75. dial: Function;
  76. disableAVModeration: Function;
  77. disableLobby: Function;
  78. enableAVModeration: Function;
  79. enableLobby: Function;
  80. end: Function;
  81. getBreakoutRooms: Function;
  82. getConnection: Function;
  83. getLocalParticipantProperty: Function;
  84. getLocalTracks: Function;
  85. getMeetingUniqueId: Function;
  86. getMetadataHandler: Function;
  87. getName: Function;
  88. getParticipantById: Function;
  89. getParticipantCount: Function;
  90. getParticipants: Function;
  91. getRole: Function;
  92. getSpeakerStats: () => ISpeakerStats;
  93. getSsrcByTrack: Function;
  94. getTranscriptionStatus: Function;
  95. grantOwner: Function;
  96. isAVModerationSupported: Function;
  97. isE2EEEnabled: Function;
  98. isE2EESupported: Function;
  99. isEndConferenceSupported: Function;
  100. isLobbySupported: Function;
  101. isP2PActive: Function;
  102. isSIPCallingSupported: Function;
  103. isStartAudioMuted: Function;
  104. isStartVideoMuted: Function;
  105. join: Function;
  106. joinLobby: Function;
  107. kickParticipant: Function;
  108. leave: Function;
  109. lobbyApproveAccess: Function;
  110. lobbyDenyAccess: Function;
  111. lock: Function;
  112. markParticipantVerified: Function;
  113. muteParticipant: Function;
  114. myLobbyUserId: Function;
  115. myUserId: Function;
  116. off: Function;
  117. on: Function;
  118. options: any;
  119. removeTrack: Function;
  120. replaceTrack: Function;
  121. room: IJitsiConferenceRoom;
  122. sendApplicationLog: Function;
  123. sendCommand: Function;
  124. sendCommandOnce: Function;
  125. sendEndpointMessage: Function;
  126. sendFaceLandmarks: (faceLandmarks: FaceLandmarks) => void;
  127. sendFeedback: Function;
  128. sendLobbyMessage: Function;
  129. sendMessage: Function;
  130. sendPrivateTextMessage: Function;
  131. sendReaction: Function;
  132. sendTextMessage: Function;
  133. sendTones: Function;
  134. sessionId: string;
  135. setAssumedBandwidthBps: (value: number) => void;
  136. setDesktopSharingFrameRate: Function;
  137. setDisplayName: Function;
  138. setIsSilent: Function;
  139. setLocalParticipantProperty: Function;
  140. setMediaEncryptionKey: Function;
  141. setReceiverConstraints: Function;
  142. setSenderVideoConstraint: Function;
  143. setStartMutedPolicy: Function;
  144. setSubject: Function;
  145. setTranscriptionLanguage: Function;
  146. startRecording: Function;
  147. startVerification: Function;
  148. stopRecording: Function;
  149. toggleE2EE: Function;
  150. }
  151. export interface IConferenceState {
  152. assumedBandwidthBps?: number;
  153. authEnabled?: boolean;
  154. authLogin?: string;
  155. authRequired?: IJitsiConference;
  156. conference?: IJitsiConference;
  157. conferenceTimestamp?: number;
  158. dataChannelOpen?: boolean;
  159. e2eeSupported?: boolean;
  160. error?: Error;
  161. followMeEnabled?: boolean;
  162. followMeRecorderEnabled?: boolean;
  163. joining?: IJitsiConference;
  164. leaving?: IJitsiConference;
  165. lobbyError?: boolean;
  166. lobbyWaitingForHost?: boolean;
  167. localSubject?: string;
  168. locked?: string;
  169. membersOnly?: IJitsiConference;
  170. metadata?: IConferenceMetadata;
  171. obfuscatedRoom?: string;
  172. obfuscatedRoomSource?: string;
  173. p2p?: Object;
  174. password?: string;
  175. passwordRequired?: IJitsiConference;
  176. pendingSubjectChange?: string;
  177. properties?: object;
  178. room?: string;
  179. startAudioMutedPolicy?: boolean;
  180. startReactionsMuted?: boolean;
  181. startVideoMutedPolicy?: boolean;
  182. subject?: string;
  183. }
  184. export interface IJitsiConferenceRoom {
  185. locked: boolean;
  186. myroomjid: string;
  187. roomjid: string;
  188. xmpp: {
  189. moderator: {
  190. logout: Function;
  191. };
  192. };
  193. }
  194. interface IConferenceFailedError extends Error {
  195. params: Array<any>;
  196. }
  197. /**
  198. * Listen for actions that contain the conference object, so that it can be
  199. * stored for use by other action creators.
  200. */
  201. ReducerRegistry.register<IConferenceState>('features/base/conference',
  202. (state = DEFAULT_STATE, action): IConferenceState => {
  203. switch (action.type) {
  204. case AUTH_STATUS_CHANGED:
  205. return _authStatusChanged(state, action);
  206. case CONFERENCE_FAILED:
  207. return _conferenceFailed(state, action);
  208. case CONFERENCE_JOINED:
  209. return _conferenceJoined(state, action);
  210. case CONFERENCE_SUBJECT_CHANGED:
  211. return set(state, 'subject', action.subject);
  212. case CONFERENCE_LOCAL_SUBJECT_CHANGED:
  213. return set(state, 'localSubject', action.localSubject);
  214. case CONFERENCE_PROPERTIES_CHANGED:
  215. return _conferencePropertiesChanged(state, action);
  216. case CONFERENCE_TIMESTAMP_CHANGED:
  217. return set(state, 'conferenceTimestamp', action.conferenceTimestamp);
  218. case CONFERENCE_LEFT:
  219. case CONFERENCE_WILL_LEAVE:
  220. return _conferenceLeftOrWillLeave(state, action);
  221. case CONFERENCE_WILL_JOIN:
  222. return _conferenceWillJoin(state, action);
  223. case CONNECTION_WILL_CONNECT:
  224. return set(state, 'authRequired', undefined);
  225. case DATA_CHANNEL_CLOSED:
  226. return set(state, 'dataChannelOpen', false);
  227. case DATA_CHANNEL_OPENED:
  228. return set(state, 'dataChannelOpen', true);
  229. case LOCK_STATE_CHANGED:
  230. return _lockStateChanged(state, action);
  231. case P2P_STATUS_CHANGED:
  232. return _p2pStatusChanged(state, action);
  233. case SET_ASSUMED_BANDWIDTH_BPS: {
  234. const assumedBandwidthBps = action.assumedBandwidthBps >= 0
  235. ? Number(action.assumedBandwidthBps)
  236. : undefined;
  237. return set(state, 'assumedBandwidthBps', assumedBandwidthBps);
  238. }
  239. case SET_FOLLOW_ME:
  240. return set(state, 'followMeEnabled', action.enabled);
  241. case SET_FOLLOW_ME_RECORDER:
  242. return { ...state,
  243. followMeRecorderEnabled: action.enabled,
  244. followMeEnabled: action.enabled
  245. };
  246. case SET_START_REACTIONS_MUTED:
  247. return set(state, 'startReactionsMuted', action.muted);
  248. case SET_LOCATION_URL:
  249. return set(state, 'room', undefined);
  250. case SET_OBFUSCATED_ROOM:
  251. return { ...state,
  252. obfuscatedRoom: action.obfuscatedRoom,
  253. obfuscatedRoomSource: action.obfuscatedRoomSource
  254. };
  255. case SET_PASSWORD:
  256. return _setPassword(state, action);
  257. case SET_PENDING_SUBJECT_CHANGE:
  258. return set(state, 'pendingSubjectChange', action.subject);
  259. case SET_ROOM:
  260. return _setRoom(state, action);
  261. case SET_START_MUTED_POLICY:
  262. return {
  263. ...state,
  264. startAudioMutedPolicy: action.startAudioMutedPolicy,
  265. startVideoMutedPolicy: action.startVideoMutedPolicy
  266. };
  267. case UPDATE_CONFERENCE_METADATA:
  268. return {
  269. ...state,
  270. metadata: action.metadata
  271. };
  272. case SET_CONFIG:
  273. return _setConfig(state, action);
  274. }
  275. return state;
  276. });
  277. /**
  278. * Processes subject and local subject of the conference based on the new config.
  279. *
  280. * @param {Object} state - The Redux state of feature base/conference.
  281. * @param {Action} action - The Redux action SET_CONFIG to reduce.
  282. * @private
  283. * @returns {Object} The new state after the reduction of the specified action.
  284. */
  285. function _setConfig(state: IConferenceState, { config }: { config: IConfig; }) {
  286. const { localSubject, subject } = config;
  287. return {
  288. ...state,
  289. localSubject,
  290. pendingSubjectChange: subject,
  291. subject: undefined
  292. };
  293. }
  294. /**
  295. * Reduces a specific Redux action AUTH_STATUS_CHANGED of the feature
  296. * base/conference.
  297. *
  298. * @param {Object} state - The Redux state of the feature base/conference.
  299. * @param {Action} action - The Redux action AUTH_STATUS_CHANGED to reduce.
  300. * @private
  301. * @returns {Object} The new state of the feature base/conference after the
  302. * reduction of the specified action.
  303. */
  304. function _authStatusChanged(state: IConferenceState,
  305. { authEnabled, authLogin }: { authEnabled: boolean; authLogin: string; }) {
  306. return assign(state, {
  307. authEnabled,
  308. authLogin
  309. });
  310. }
  311. /**
  312. * Reduces a specific Redux action CONFERENCE_FAILED of the feature
  313. * base/conference.
  314. *
  315. * @param {Object} state - The Redux state of the feature base/conference.
  316. * @param {Action} action - The Redux action CONFERENCE_FAILED to reduce.
  317. * @private
  318. * @returns {Object} The new state of the feature base/conference after the
  319. * reduction of the specified action.
  320. */
  321. function _conferenceFailed(state: IConferenceState, { conference, error }: {
  322. conference: IJitsiConference; error: IConferenceFailedError; }) {
  323. // The current (similar to getCurrentConference in
  324. // base/conference/functions.any.js) conference which is joining or joined:
  325. const conference_ = state.conference || state.joining;
  326. if (conference_ && conference_ !== conference) {
  327. return state;
  328. }
  329. let authRequired;
  330. let membersOnly;
  331. let passwordRequired;
  332. let lobbyWaitingForHost;
  333. let lobbyError;
  334. switch (error.name) {
  335. case JitsiConferenceErrors.AUTHENTICATION_REQUIRED:
  336. authRequired = conference;
  337. break;
  338. /**
  339. * Access denied while waiting in the lobby.
  340. * A conference error when we tried to join into a room with no display name when lobby is enabled in the room.
  341. */
  342. case JitsiConferenceErrors.CONFERENCE_ACCESS_DENIED:
  343. case JitsiConferenceErrors.DISPLAY_NAME_REQUIRED: {
  344. lobbyError = true;
  345. break;
  346. }
  347. case JitsiConferenceErrors.MEMBERS_ONLY_ERROR: {
  348. membersOnly = conference;
  349. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  350. const [ _lobbyJid, _lobbyWaitingForHost ] = error.params;
  351. lobbyWaitingForHost = _lobbyWaitingForHost;
  352. break;
  353. }
  354. case JitsiConferenceErrors.PASSWORD_REQUIRED:
  355. passwordRequired = conference;
  356. break;
  357. }
  358. return assign(state, {
  359. authRequired,
  360. conference: undefined,
  361. e2eeSupported: undefined,
  362. error,
  363. joining: undefined,
  364. leaving: undefined,
  365. lobbyError,
  366. lobbyWaitingForHost,
  367. /**
  368. * The indicator of how the conference/room is locked. If falsy, the
  369. * conference/room is unlocked; otherwise, it's either
  370. * {@code LOCKED_LOCALLY} or {@code LOCKED_REMOTELY}.
  371. *
  372. * @type {string}
  373. */
  374. locked: passwordRequired ? LOCKED_REMOTELY : undefined,
  375. membersOnly,
  376. password: undefined,
  377. /**
  378. * The JitsiConference instance which requires a password to join.
  379. *
  380. * @type {JitsiConference}
  381. */
  382. passwordRequired
  383. });
  384. }
  385. /**
  386. * Reduces a specific Redux action CONFERENCE_JOINED of the feature
  387. * base/conference.
  388. *
  389. * @param {Object} state - The Redux state of the feature base/conference.
  390. * @param {Action} action - The Redux action CONFERENCE_JOINED to reduce.
  391. * @private
  392. * @returns {Object} The new state of the feature base/conference after the
  393. * reduction of the specified action.
  394. */
  395. function _conferenceJoined(state: IConferenceState, { conference }: { conference: IJitsiConference; }) {
  396. // FIXME The indicator which determines whether a JitsiConference is locked
  397. // i.e. password-protected is private to lib-jitsi-meet. However, the
  398. // library does not fire LOCK_STATE_CHANGED upon joining a JitsiConference
  399. // with a password.
  400. // FIXME Technically JitsiConference.room is a private field.
  401. const locked = conference.room?.locked ? LOCKED_REMOTELY : undefined;
  402. return assign(state, {
  403. authRequired: undefined,
  404. /**
  405. * The JitsiConference instance represented by the Redux state of the
  406. * feature base/conference.
  407. *
  408. * @type {JitsiConference}
  409. */
  410. conference,
  411. e2eeSupported: conference.isE2EESupported(),
  412. joining: undefined,
  413. membersOnly: undefined,
  414. leaving: undefined,
  415. lobbyError: undefined,
  416. lobbyWaitingForHost: undefined,
  417. /**
  418. * The indicator which determines whether the conference is locked.
  419. *
  420. * @type {boolean}
  421. */
  422. locked,
  423. passwordRequired: undefined
  424. });
  425. }
  426. /**
  427. * Reduces a specific redux action {@link CONFERENCE_LEFT} or
  428. * {@link CONFERENCE_WILL_LEAVE} for the feature base/conference.
  429. *
  430. * @param {Object} state - The redux state of the feature base/conference.
  431. * @param {Action} action - The redux action {@code CONFERENCE_LEFT} or
  432. * {@code CONFERENCE_WILL_LEAVE} to reduce.
  433. * @private
  434. * @returns {Object} The next/new state of the feature base/conference after the
  435. * reduction of the specified action.
  436. */
  437. function _conferenceLeftOrWillLeave(state: IConferenceState, { conference, type }:
  438. { conference: IJitsiConference; type: string; }) {
  439. const nextState = { ...state };
  440. // The redux action CONFERENCE_LEFT is the last time that we should be
  441. // hearing from a JitsiConference instance.
  442. //
  443. // The redux action CONFERENCE_WILL_LEAVE represents the order of the user
  444. // to leave a JitsiConference instance. From the user's perspective, there's
  445. // no going back (with respect to the instance itself). The app will perform
  446. // due clean-up like leaving the associated room, but the instance is no
  447. // longer the focus of the attention of the user and, consequently, the app.
  448. for (const p in state) {
  449. if (state[p as keyof IConferenceState] === conference) {
  450. nextState[p as keyof IConferenceState] = undefined;
  451. switch (p) {
  452. case 'conference':
  453. case 'passwordRequired':
  454. // XXX Clear/unset locked & password for a conference which has
  455. // been LOCKED_LOCALLY or LOCKED_REMOTELY.
  456. delete nextState.locked;
  457. delete nextState.password;
  458. break;
  459. }
  460. }
  461. }
  462. if (type === CONFERENCE_WILL_LEAVE) {
  463. // A CONFERENCE_WILL_LEAVE is of further consequence only if it is
  464. // expected i.e. if the specified conference is joining or joined.
  465. if (conference === state.joining || conference === state.conference) {
  466. /**
  467. * The JitsiConference instance which is currently in the process of
  468. * being left.
  469. *
  470. * @type {JitsiConference}
  471. */
  472. nextState.leaving = conference;
  473. }
  474. }
  475. return nextState;
  476. }
  477. /**
  478. * Reduces a specific Redux action CONFERENCE_PROPERTIES_CHANGED of the feature
  479. * base/conference.
  480. *
  481. * @param {Object} state - The Redux state of the feature base/conference.
  482. * @param {Action} action - The Redux action CONFERENCE_PROPERTIES_CHANGED to reduce.
  483. * @private
  484. * @returns {Object} The new state of the feature base/conference after the
  485. * reduction of the specified action.
  486. */
  487. function _conferencePropertiesChanged(state: IConferenceState, { properties }: { properties: Object; }) {
  488. if (!equals(state.properties, properties)) {
  489. return assign(state, {
  490. properties
  491. });
  492. }
  493. return state;
  494. }
  495. /**
  496. * Reduces a specific Redux action CONFERENCE_WILL_JOIN of the feature
  497. * base/conference.
  498. *
  499. * @param {Object} state - The Redux state of the feature base/conference.
  500. * @param {Action} action - The Redux action CONFERENCE_WILL_JOIN to reduce.
  501. * @private
  502. * @returns {Object} The new state of the feature base/conference after the
  503. * reduction of the specified action.
  504. */
  505. function _conferenceWillJoin(state: IConferenceState, { conference }: { conference: IJitsiConference; }) {
  506. return assign(state, {
  507. error: undefined,
  508. joining: conference
  509. });
  510. }
  511. /**
  512. * Reduces a specific Redux action LOCK_STATE_CHANGED of the feature
  513. * base/conference.
  514. *
  515. * @param {Object} state - The Redux state of the feature base/conference.
  516. * @param {Action} action - The Redux action LOCK_STATE_CHANGED to reduce.
  517. * @private
  518. * @returns {Object} The new state of the feature base/conference after the
  519. * reduction of the specified action.
  520. */
  521. function _lockStateChanged(state: IConferenceState, { conference, locked }: { conference: Object; locked: boolean; }) {
  522. if (state.conference !== conference) {
  523. return state;
  524. }
  525. return assign(state, {
  526. locked: locked ? state.locked || LOCKED_REMOTELY : undefined,
  527. password: locked ? state.password : undefined
  528. });
  529. }
  530. /**
  531. * Reduces a specific Redux action P2P_STATUS_CHANGED of the feature
  532. * base/conference.
  533. *
  534. * @param {Object} state - The Redux state of the feature base/conference.
  535. * @param {Action} action - The Redux action P2P_STATUS_CHANGED to reduce.
  536. * @private
  537. * @returns {Object} The new state of the feature base/conference after the
  538. * reduction of the specified action.
  539. */
  540. function _p2pStatusChanged(state: IConferenceState, action: AnyAction) {
  541. return set(state, 'p2p', action.p2p);
  542. }
  543. /**
  544. * Reduces a specific Redux action SET_PASSWORD of the feature base/conference.
  545. *
  546. * @param {Object} state - The Redux state of the feature base/conference.
  547. * @param {Action} action - The Redux action SET_PASSWORD to reduce.
  548. * @private
  549. * @returns {Object} The new state of the feature base/conference after the
  550. * reduction of the specified action.
  551. */
  552. function _setPassword(state: IConferenceState, { conference, method, password }: {
  553. conference: IJitsiConference; method: Object; password: string; }) {
  554. switch (method) {
  555. case conference.join:
  556. return assign(state, {
  557. // 1. The JitsiConference which transitions away from
  558. // passwordRequired MUST remain in the redux state
  559. // features/base/conference until it transitions into
  560. // conference; otherwise, there is a span of time during which
  561. // the redux state does not even know that there is a
  562. // JitsiConference whatsoever.
  563. //
  564. // 2. The redux action setPassword will attempt to join the
  565. // JitsiConference so joining is an appropriate transitional
  566. // redux state.
  567. //
  568. // 3. The redux action setPassword will perform the same check
  569. // before it proceeds with the re-join.
  570. joining: state.conference ? state.joining : conference,
  571. locked: LOCKED_REMOTELY,
  572. /**
  573. * The password with which the conference is to be joined.
  574. *
  575. * @type {string}
  576. */
  577. password
  578. });
  579. case conference.lock:
  580. return assign(state, {
  581. locked: password ? LOCKED_LOCALLY : undefined,
  582. password
  583. });
  584. }
  585. return state;
  586. }
  587. /**
  588. * Reduces a specific Redux action SET_ROOM of the feature base/conference.
  589. *
  590. * @param {Object} state - The Redux state of the feature base/conference.
  591. * @param {Action} action - The Redux action SET_ROOM to reduce.
  592. * @private
  593. * @returns {Object} The new state of the feature base/conference after the
  594. * reduction of the specified action.
  595. */
  596. function _setRoom(state: IConferenceState, action: AnyAction) {
  597. let { room } = action;
  598. if (!isRoomValid(room)) {
  599. // Technically, there are multiple values which don't represent valid
  600. // room names. Practically, each of them is as bad as the rest of them
  601. // because we can't use any of them to join a conference.
  602. room = undefined;
  603. }
  604. /**
  605. * The name of the room of the conference (to be) joined.
  606. *
  607. * @type {string}
  608. */
  609. return assign(state, {
  610. error: undefined,
  611. room
  612. });
  613. }