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.

reducer.ts 21KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. startRecording: Function;
  146. startVerification: Function;
  147. stopRecording: Function;
  148. toggleE2EE: Function;
  149. }
  150. export interface IConferenceState {
  151. assumedBandwidthBps?: number;
  152. authEnabled?: boolean;
  153. authLogin?: string;
  154. authRequired?: IJitsiConference;
  155. conference?: IJitsiConference;
  156. conferenceTimestamp?: number;
  157. dataChannelOpen?: boolean;
  158. e2eeSupported?: boolean;
  159. error?: Error;
  160. followMeEnabled?: boolean;
  161. followMeRecorderEnabled?: boolean;
  162. joining?: IJitsiConference;
  163. leaving?: IJitsiConference;
  164. lobbyError?: boolean;
  165. lobbyWaitingForHost?: boolean;
  166. localSubject?: string;
  167. locked?: string;
  168. membersOnly?: IJitsiConference;
  169. metadata?: IConferenceMetadata;
  170. obfuscatedRoom?: string;
  171. obfuscatedRoomSource?: string;
  172. p2p?: Object;
  173. password?: string;
  174. passwordRequired?: IJitsiConference;
  175. pendingSubjectChange?: string;
  176. properties?: object;
  177. room?: string;
  178. startAudioMutedPolicy?: boolean;
  179. startReactionsMuted?: boolean;
  180. startVideoMutedPolicy?: boolean;
  181. subject?: string;
  182. }
  183. export interface IJitsiConferenceRoom {
  184. locked: boolean;
  185. myroomjid: string;
  186. roomjid: string;
  187. xmpp: {
  188. moderator: {
  189. logout: Function;
  190. };
  191. };
  192. }
  193. interface IConferenceFailedError extends Error {
  194. params: Array<any>;
  195. }
  196. /**
  197. * Listen for actions that contain the conference object, so that it can be
  198. * stored for use by other action creators.
  199. */
  200. ReducerRegistry.register<IConferenceState>('features/base/conference',
  201. (state = DEFAULT_STATE, action): IConferenceState => {
  202. switch (action.type) {
  203. case AUTH_STATUS_CHANGED:
  204. return _authStatusChanged(state, action);
  205. case CONFERENCE_FAILED:
  206. return _conferenceFailed(state, action);
  207. case CONFERENCE_JOINED:
  208. return _conferenceJoined(state, action);
  209. case CONFERENCE_SUBJECT_CHANGED:
  210. return set(state, 'subject', action.subject);
  211. case CONFERENCE_LOCAL_SUBJECT_CHANGED:
  212. return set(state, 'localSubject', action.localSubject);
  213. case CONFERENCE_PROPERTIES_CHANGED:
  214. return _conferencePropertiesChanged(state, action);
  215. case CONFERENCE_TIMESTAMP_CHANGED:
  216. return set(state, 'conferenceTimestamp', action.conferenceTimestamp);
  217. case CONFERENCE_LEFT:
  218. case CONFERENCE_WILL_LEAVE:
  219. return _conferenceLeftOrWillLeave(state, action);
  220. case CONFERENCE_WILL_JOIN:
  221. return _conferenceWillJoin(state, action);
  222. case CONNECTION_WILL_CONNECT:
  223. return set(state, 'authRequired', undefined);
  224. case DATA_CHANNEL_CLOSED:
  225. return set(state, 'dataChannelOpen', false);
  226. case DATA_CHANNEL_OPENED:
  227. return set(state, 'dataChannelOpen', true);
  228. case LOCK_STATE_CHANGED:
  229. return _lockStateChanged(state, action);
  230. case P2P_STATUS_CHANGED:
  231. return _p2pStatusChanged(state, action);
  232. case SET_ASSUMED_BANDWIDTH_BPS: {
  233. const assumedBandwidthBps = action.assumedBandwidthBps >= 0
  234. ? Number(action.assumedBandwidthBps)
  235. : undefined;
  236. return set(state, 'assumedBandwidthBps', assumedBandwidthBps);
  237. }
  238. case SET_FOLLOW_ME:
  239. return set(state, 'followMeEnabled', action.enabled);
  240. case SET_FOLLOW_ME_RECORDER:
  241. return { ...state,
  242. followMeRecorderEnabled: action.enabled,
  243. followMeEnabled: action.enabled
  244. };
  245. case SET_START_REACTIONS_MUTED:
  246. return set(state, 'startReactionsMuted', action.muted);
  247. case SET_LOCATION_URL:
  248. return set(state, 'room', undefined);
  249. case SET_OBFUSCATED_ROOM:
  250. return { ...state,
  251. obfuscatedRoom: action.obfuscatedRoom,
  252. obfuscatedRoomSource: action.obfuscatedRoomSource
  253. };
  254. case SET_PASSWORD:
  255. return _setPassword(state, action);
  256. case SET_PENDING_SUBJECT_CHANGE:
  257. return set(state, 'pendingSubjectChange', action.subject);
  258. case SET_ROOM:
  259. return _setRoom(state, action);
  260. case SET_START_MUTED_POLICY:
  261. return {
  262. ...state,
  263. startAudioMutedPolicy: action.startAudioMutedPolicy,
  264. startVideoMutedPolicy: action.startVideoMutedPolicy
  265. };
  266. case UPDATE_CONFERENCE_METADATA:
  267. return {
  268. ...state,
  269. metadata: action.metadata
  270. };
  271. case SET_CONFIG:
  272. return _setConfig(state, action);
  273. }
  274. return state;
  275. });
  276. /**
  277. * Processes subject and local subject of the conference based on the new config.
  278. *
  279. * @param {Object} state - The Redux state of feature base/conference.
  280. * @param {Action} action - The Redux action SET_CONFIG to reduce.
  281. * @private
  282. * @returns {Object} The new state after the reduction of the specified action.
  283. */
  284. function _setConfig(state: IConferenceState, { config }: { config: IConfig; }) {
  285. const { localSubject, subject } = config;
  286. return {
  287. ...state,
  288. localSubject,
  289. pendingSubjectChange: subject,
  290. subject: undefined
  291. };
  292. }
  293. /**
  294. * Reduces a specific Redux action AUTH_STATUS_CHANGED of the feature
  295. * base/conference.
  296. *
  297. * @param {Object} state - The Redux state of the feature base/conference.
  298. * @param {Action} action - The Redux action AUTH_STATUS_CHANGED to reduce.
  299. * @private
  300. * @returns {Object} The new state of the feature base/conference after the
  301. * reduction of the specified action.
  302. */
  303. function _authStatusChanged(state: IConferenceState,
  304. { authEnabled, authLogin }: { authEnabled: boolean; authLogin: string; }) {
  305. return assign(state, {
  306. authEnabled,
  307. authLogin
  308. });
  309. }
  310. /**
  311. * Reduces a specific Redux action CONFERENCE_FAILED of the feature
  312. * base/conference.
  313. *
  314. * @param {Object} state - The Redux state of the feature base/conference.
  315. * @param {Action} action - The Redux action CONFERENCE_FAILED to reduce.
  316. * @private
  317. * @returns {Object} The new state of the feature base/conference after the
  318. * reduction of the specified action.
  319. */
  320. function _conferenceFailed(state: IConferenceState, { conference, error }: {
  321. conference: IJitsiConference; error: IConferenceFailedError; }) {
  322. // The current (similar to getCurrentConference in
  323. // base/conference/functions.any.js) conference which is joining or joined:
  324. const conference_ = state.conference || state.joining;
  325. if (conference_ && conference_ !== conference) {
  326. return state;
  327. }
  328. let authRequired;
  329. let membersOnly;
  330. let passwordRequired;
  331. let lobbyWaitingForHost;
  332. let lobbyError;
  333. switch (error.name) {
  334. case JitsiConferenceErrors.AUTHENTICATION_REQUIRED:
  335. authRequired = conference;
  336. break;
  337. /**
  338. * Access denied while waiting in the lobby.
  339. * A conference error when we tried to join into a room with no display name when lobby is enabled in the room.
  340. */
  341. case JitsiConferenceErrors.CONFERENCE_ACCESS_DENIED:
  342. case JitsiConferenceErrors.DISPLAY_NAME_REQUIRED: {
  343. lobbyError = true;
  344. break;
  345. }
  346. case JitsiConferenceErrors.MEMBERS_ONLY_ERROR: {
  347. membersOnly = conference;
  348. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  349. const [ _lobbyJid, _lobbyWaitingForHost ] = error.params;
  350. lobbyWaitingForHost = _lobbyWaitingForHost;
  351. break;
  352. }
  353. case JitsiConferenceErrors.PASSWORD_REQUIRED:
  354. passwordRequired = conference;
  355. break;
  356. }
  357. return assign(state, {
  358. authRequired,
  359. conference: undefined,
  360. e2eeSupported: undefined,
  361. error,
  362. joining: undefined,
  363. leaving: undefined,
  364. lobbyError,
  365. lobbyWaitingForHost,
  366. /**
  367. * The indicator of how the conference/room is locked. If falsy, the
  368. * conference/room is unlocked; otherwise, it's either
  369. * {@code LOCKED_LOCALLY} or {@code LOCKED_REMOTELY}.
  370. *
  371. * @type {string}
  372. */
  373. locked: passwordRequired ? LOCKED_REMOTELY : undefined,
  374. membersOnly,
  375. password: undefined,
  376. /**
  377. * The JitsiConference instance which requires a password to join.
  378. *
  379. * @type {JitsiConference}
  380. */
  381. passwordRequired
  382. });
  383. }
  384. /**
  385. * Reduces a specific Redux action CONFERENCE_JOINED of the feature
  386. * base/conference.
  387. *
  388. * @param {Object} state - The Redux state of the feature base/conference.
  389. * @param {Action} action - The Redux action CONFERENCE_JOINED to reduce.
  390. * @private
  391. * @returns {Object} The new state of the feature base/conference after the
  392. * reduction of the specified action.
  393. */
  394. function _conferenceJoined(state: IConferenceState, { conference }: { conference: IJitsiConference; }) {
  395. // FIXME The indicator which determines whether a JitsiConference is locked
  396. // i.e. password-protected is private to lib-jitsi-meet. However, the
  397. // library does not fire LOCK_STATE_CHANGED upon joining a JitsiConference
  398. // with a password.
  399. // FIXME Technically JitsiConference.room is a private field.
  400. const locked = conference.room?.locked ? LOCKED_REMOTELY : undefined;
  401. return assign(state, {
  402. authRequired: undefined,
  403. /**
  404. * The JitsiConference instance represented by the Redux state of the
  405. * feature base/conference.
  406. *
  407. * @type {JitsiConference}
  408. */
  409. conference,
  410. e2eeSupported: conference.isE2EESupported(),
  411. joining: undefined,
  412. membersOnly: undefined,
  413. leaving: undefined,
  414. lobbyError: undefined,
  415. lobbyWaitingForHost: undefined,
  416. /**
  417. * The indicator which determines whether the conference is locked.
  418. *
  419. * @type {boolean}
  420. */
  421. locked,
  422. passwordRequired: undefined
  423. });
  424. }
  425. /**
  426. * Reduces a specific redux action {@link CONFERENCE_LEFT} or
  427. * {@link CONFERENCE_WILL_LEAVE} for the feature base/conference.
  428. *
  429. * @param {Object} state - The redux state of the feature base/conference.
  430. * @param {Action} action - The redux action {@code CONFERENCE_LEFT} or
  431. * {@code CONFERENCE_WILL_LEAVE} to reduce.
  432. * @private
  433. * @returns {Object} The next/new state of the feature base/conference after the
  434. * reduction of the specified action.
  435. */
  436. function _conferenceLeftOrWillLeave(state: IConferenceState, { conference, type }:
  437. { conference: IJitsiConference; type: string; }) {
  438. const nextState = { ...state };
  439. // The redux action CONFERENCE_LEFT is the last time that we should be
  440. // hearing from a JitsiConference instance.
  441. //
  442. // The redux action CONFERENCE_WILL_LEAVE represents the order of the user
  443. // to leave a JitsiConference instance. From the user's perspective, there's
  444. // no going back (with respect to the instance itself). The app will perform
  445. // due clean-up like leaving the associated room, but the instance is no
  446. // longer the focus of the attention of the user and, consequently, the app.
  447. for (const p in state) {
  448. if (state[p as keyof IConferenceState] === conference) {
  449. nextState[p as keyof IConferenceState] = undefined;
  450. switch (p) {
  451. case 'conference':
  452. case 'passwordRequired':
  453. // XXX Clear/unset locked & password for a conference which has
  454. // been LOCKED_LOCALLY or LOCKED_REMOTELY.
  455. delete nextState.locked;
  456. delete nextState.password;
  457. break;
  458. }
  459. }
  460. }
  461. if (type === CONFERENCE_WILL_LEAVE) {
  462. // A CONFERENCE_WILL_LEAVE is of further consequence only if it is
  463. // expected i.e. if the specified conference is joining or joined.
  464. if (conference === state.joining || conference === state.conference) {
  465. /**
  466. * The JitsiConference instance which is currently in the process of
  467. * being left.
  468. *
  469. * @type {JitsiConference}
  470. */
  471. nextState.leaving = conference;
  472. }
  473. }
  474. return nextState;
  475. }
  476. /**
  477. * Reduces a specific Redux action CONFERENCE_PROPERTIES_CHANGED of the feature
  478. * base/conference.
  479. *
  480. * @param {Object} state - The Redux state of the feature base/conference.
  481. * @param {Action} action - The Redux action CONFERENCE_PROPERTIES_CHANGED to reduce.
  482. * @private
  483. * @returns {Object} The new state of the feature base/conference after the
  484. * reduction of the specified action.
  485. */
  486. function _conferencePropertiesChanged(state: IConferenceState, { properties }: { properties: Object; }) {
  487. if (!equals(state.properties, properties)) {
  488. return assign(state, {
  489. properties
  490. });
  491. }
  492. return state;
  493. }
  494. /**
  495. * Reduces a specific Redux action CONFERENCE_WILL_JOIN of the feature
  496. * base/conference.
  497. *
  498. * @param {Object} state - The Redux state of the feature base/conference.
  499. * @param {Action} action - The Redux action CONFERENCE_WILL_JOIN to reduce.
  500. * @private
  501. * @returns {Object} The new state of the feature base/conference after the
  502. * reduction of the specified action.
  503. */
  504. function _conferenceWillJoin(state: IConferenceState, { conference }: { conference: IJitsiConference; }) {
  505. return assign(state, {
  506. error: undefined,
  507. joining: conference
  508. });
  509. }
  510. /**
  511. * Reduces a specific Redux action LOCK_STATE_CHANGED of the feature
  512. * base/conference.
  513. *
  514. * @param {Object} state - The Redux state of the feature base/conference.
  515. * @param {Action} action - The Redux action LOCK_STATE_CHANGED to reduce.
  516. * @private
  517. * @returns {Object} The new state of the feature base/conference after the
  518. * reduction of the specified action.
  519. */
  520. function _lockStateChanged(state: IConferenceState, { conference, locked }: { conference: Object; locked: boolean; }) {
  521. if (state.conference !== conference) {
  522. return state;
  523. }
  524. return assign(state, {
  525. locked: locked ? state.locked || LOCKED_REMOTELY : undefined,
  526. password: locked ? state.password : undefined
  527. });
  528. }
  529. /**
  530. * Reduces a specific Redux action P2P_STATUS_CHANGED of the feature
  531. * base/conference.
  532. *
  533. * @param {Object} state - The Redux state of the feature base/conference.
  534. * @param {Action} action - The Redux action P2P_STATUS_CHANGED to reduce.
  535. * @private
  536. * @returns {Object} The new state of the feature base/conference after the
  537. * reduction of the specified action.
  538. */
  539. function _p2pStatusChanged(state: IConferenceState, action: AnyAction) {
  540. return set(state, 'p2p', action.p2p);
  541. }
  542. /**
  543. * Reduces a specific Redux action SET_PASSWORD of the feature base/conference.
  544. *
  545. * @param {Object} state - The Redux state of the feature base/conference.
  546. * @param {Action} action - The Redux action SET_PASSWORD to reduce.
  547. * @private
  548. * @returns {Object} The new state of the feature base/conference after the
  549. * reduction of the specified action.
  550. */
  551. function _setPassword(state: IConferenceState, { conference, method, password }: {
  552. conference: IJitsiConference; method: Object; password: string; }) {
  553. switch (method) {
  554. case conference.join:
  555. return assign(state, {
  556. // 1. The JitsiConference which transitions away from
  557. // passwordRequired MUST remain in the redux state
  558. // features/base/conference until it transitions into
  559. // conference; otherwise, there is a span of time during which
  560. // the redux state does not even know that there is a
  561. // JitsiConference whatsoever.
  562. //
  563. // 2. The redux action setPassword will attempt to join the
  564. // JitsiConference so joining is an appropriate transitional
  565. // redux state.
  566. //
  567. // 3. The redux action setPassword will perform the same check
  568. // before it proceeds with the re-join.
  569. joining: state.conference ? state.joining : conference,
  570. locked: LOCKED_REMOTELY,
  571. /**
  572. * The password with which the conference is to be joined.
  573. *
  574. * @type {string}
  575. */
  576. password
  577. });
  578. case conference.lock:
  579. return assign(state, {
  580. locked: password ? LOCKED_LOCALLY : undefined,
  581. password
  582. });
  583. }
  584. return state;
  585. }
  586. /**
  587. * Reduces a specific Redux action SET_ROOM of the feature base/conference.
  588. *
  589. * @param {Object} state - The Redux state of the feature base/conference.
  590. * @param {Action} action - The Redux action SET_ROOM to reduce.
  591. * @private
  592. * @returns {Object} The new state of the feature base/conference after the
  593. * reduction of the specified action.
  594. */
  595. function _setRoom(state: IConferenceState, action: AnyAction) {
  596. let { room } = action;
  597. if (!isRoomValid(room)) {
  598. // Technically, there are multiple values which don't represent valid
  599. // room names. Practically, each of them is as bad as the rest of them
  600. // because we can't use any of them to join a conference.
  601. room = undefined;
  602. }
  603. /**
  604. * The name of the room of the conference (to be) joined.
  605. *
  606. * @type {string}
  607. */
  608. return assign(state, {
  609. error: undefined,
  610. room
  611. });
  612. }