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.

functions.ts 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /* eslint-disable lines-around-comment */
  2. // @ts-ignore
  3. import { getGravatarURL } from '@jitsi/js-utils/avatar';
  4. import { IReduxState, IStore } from '../../app/types';
  5. // @ts-ignore
  6. import { isStageFilmstripAvailable } from '../../filmstrip/functions';
  7. import { IStateful } from '../app/types';
  8. import { GRAVATAR_BASE_URL } from '../avatar/constants';
  9. import { isCORSAvatarURL } from '../avatar/functions';
  10. import i18next from '../i18n/i18next';
  11. import { VIDEO_TYPE } from '../media/constants';
  12. import { toState } from '../redux/functions';
  13. import { getScreenShareTrack } from '../tracks/functions';
  14. import { createDeferred } from '../util/helpers';
  15. import {
  16. JIGASI_PARTICIPANT_ICON,
  17. MAX_DISPLAY_NAME_LENGTH,
  18. PARTICIPANT_ROLE,
  19. WHITEBOARD_PARTICIPANT_ICON
  20. } from './constants';
  21. // @ts-ignore
  22. import { preloadImage } from './preloadImage';
  23. import { FakeParticipant, IParticipant } from './types';
  24. /**
  25. * Temp structures for avatar urls to be checked/preloaded.
  26. */
  27. const AVATAR_QUEUE: Object[] = [];
  28. const AVATAR_CHECKED_URLS = new Map();
  29. /* eslint-disable arrow-body-style, no-unused-vars */
  30. const AVATAR_CHECKER_FUNCTIONS = [
  31. (participant: IParticipant) => {
  32. return isJigasiParticipant(participant) ? JIGASI_PARTICIPANT_ICON : null;
  33. },
  34. (participant: IParticipant) => {
  35. return isWhiteboardParticipant(participant) ? WHITEBOARD_PARTICIPANT_ICON : null;
  36. },
  37. (participant: IParticipant) => {
  38. return participant?.avatarURL ? participant.avatarURL : null;
  39. },
  40. (participant: IParticipant, store: IStore) => {
  41. const config = store.getState()['features/base/config'];
  42. const isGravatarDisabled = config.gravatar?.disabled;
  43. if (participant?.email && !isGravatarDisabled) {
  44. const gravatarBaseURL = config.gravatar?.baseUrl
  45. || config.gravatarBaseURL
  46. || GRAVATAR_BASE_URL;
  47. return getGravatarURL(participant.email, gravatarBaseURL);
  48. }
  49. return null;
  50. }
  51. ];
  52. /* eslint-enable arrow-body-style, no-unused-vars */
  53. /**
  54. * Returns the list of active speakers that should be moved to the top of the sorted list of participants so that the
  55. * dominant speaker is visible always on the vertical filmstrip in stage layout.
  56. *
  57. * @param {Function | Object} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
  58. * retrieve the state.
  59. * @returns {Array<string>}
  60. */
  61. export function getActiveSpeakersToBeDisplayed(stateful: IStateful) {
  62. const state = toState(stateful);
  63. const {
  64. dominantSpeaker,
  65. fakeParticipants,
  66. sortedRemoteVirtualScreenshareParticipants,
  67. speakersList
  68. } = state['features/base/participants'];
  69. const { visibleRemoteParticipants } = state['features/filmstrip'];
  70. let activeSpeakers = new Map(speakersList);
  71. // Do not re-sort the active speakers if dominant speaker is currently visible.
  72. if (dominantSpeaker && visibleRemoteParticipants.has(dominantSpeaker)) {
  73. return activeSpeakers;
  74. }
  75. let availableSlotsForActiveSpeakers = visibleRemoteParticipants.size;
  76. if (activeSpeakers.has(dominantSpeaker ?? '')) {
  77. activeSpeakers.delete(dominantSpeaker ?? '');
  78. }
  79. // Add dominant speaker to the beginning of the list (not including self) since the active speaker list is always
  80. // alphabetically sorted.
  81. if (dominantSpeaker && dominantSpeaker !== getLocalParticipant(state)?.id) {
  82. const updatedSpeakers = Array.from(activeSpeakers);
  83. updatedSpeakers.splice(0, 0, [ dominantSpeaker, getParticipantById(state, dominantSpeaker)?.name ?? '' ]);
  84. activeSpeakers = new Map(updatedSpeakers);
  85. }
  86. // Remove screenshares from the count.
  87. if (sortedRemoteVirtualScreenshareParticipants) {
  88. availableSlotsForActiveSpeakers -= sortedRemoteVirtualScreenshareParticipants.size * 2;
  89. for (const screenshare of Array.from(sortedRemoteVirtualScreenshareParticipants.keys())) {
  90. const ownerId = getVirtualScreenshareParticipantOwnerId(screenshare as string);
  91. activeSpeakers.delete(ownerId);
  92. }
  93. }
  94. // Remove fake participants from the count.
  95. if (fakeParticipants) {
  96. availableSlotsForActiveSpeakers -= fakeParticipants.size;
  97. }
  98. const truncatedSpeakersList = Array.from(activeSpeakers).slice(0, availableSlotsForActiveSpeakers);
  99. truncatedSpeakersList.sort((a: any, b: any) => a[1].localeCompare(b[1]));
  100. return new Map(truncatedSpeakersList);
  101. }
  102. /**
  103. * Resolves the first loadable avatar URL for a participant.
  104. *
  105. * @param {Object} participant - The participant to resolve avatars for.
  106. * @param {Store} store - Redux store.
  107. * @returns {Promise}
  108. */
  109. export function getFirstLoadableAvatarUrl(participant: IParticipant, store: IStore) {
  110. const deferred: any = createDeferred();
  111. const fullPromise = deferred.promise
  112. .then(() => _getFirstLoadableAvatarUrl(participant, store))
  113. .then((result: any) => {
  114. if (AVATAR_QUEUE.length) {
  115. const next: any = AVATAR_QUEUE.shift();
  116. next.resolve();
  117. }
  118. return result;
  119. });
  120. if (AVATAR_QUEUE.length) {
  121. AVATAR_QUEUE.push(deferred);
  122. } else {
  123. deferred.resolve();
  124. }
  125. return fullPromise;
  126. }
  127. /**
  128. * Returns local participant from Redux state.
  129. *
  130. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  131. * {@code getState} function to be used to retrieve the state
  132. * features/base/participants.
  133. * @returns {(IParticipant|undefined)}
  134. */
  135. export function getLocalParticipant(stateful: IStateful) {
  136. const state = toState(stateful)['features/base/participants'];
  137. return state.local;
  138. }
  139. /**
  140. * Returns local screen share participant from Redux state.
  141. *
  142. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  143. * {@code getState} function to be used to retrieve the state features/base/participants.
  144. * @returns {(IParticipant|undefined)}
  145. */
  146. export function getLocalScreenShareParticipant(stateful: IStateful) {
  147. const state = toState(stateful)['features/base/participants'];
  148. return state.localScreenShare;
  149. }
  150. /**
  151. * Returns screenshare participant.
  152. *
  153. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
  154. * retrieve the state features/base/participants.
  155. * @param {string} id - The owner ID of the screenshare participant to retrieve.
  156. * @returns {(IParticipant|undefined)}
  157. */
  158. export function getVirtualScreenshareParticipantByOwnerId(stateful: IStateful, id: string) {
  159. const state = toState(stateful);
  160. const track = getScreenShareTrack(state['features/base/tracks'], id);
  161. return getParticipantById(stateful, track?.jitsiTrack.getSourceName());
  162. }
  163. /**
  164. * Normalizes a display name so then no invalid values (padding, length...etc)
  165. * can be set.
  166. *
  167. * @param {string} name - The display name to set.
  168. * @returns {string}
  169. */
  170. export function getNormalizedDisplayName(name: string) {
  171. if (!name || !name.trim()) {
  172. return undefined;
  173. }
  174. return name.trim().substring(0, MAX_DISPLAY_NAME_LENGTH);
  175. }
  176. /**
  177. * Returns participant by ID from Redux state.
  178. *
  179. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  180. * {@code getState} function to be used to retrieve the state
  181. * features/base/participants.
  182. * @param {string} id - The ID of the participant to retrieve.
  183. * @private
  184. * @returns {(IParticipant|undefined)}
  185. */
  186. export function getParticipantById(stateful: IStateful, id: string): IParticipant | undefined {
  187. const state = toState(stateful)['features/base/participants'];
  188. const { local, localScreenShare, remote } = state;
  189. return remote.get(id)
  190. || (local?.id === id ? local : undefined)
  191. || (localScreenShare?.id === id ? localScreenShare : undefined);
  192. }
  193. /**
  194. * Returns the participant with the ID matching the passed ID or the local participant if the ID is
  195. * undefined.
  196. *
  197. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  198. * {@code getState} function to be used to retrieve the state
  199. * features/base/participants.
  200. * @param {string|undefined} [participantID] - An optional partipantID argument.
  201. * @returns {IParticipant|undefined}
  202. */
  203. export function getParticipantByIdOrUndefined(stateful: IStateful, participantID?: string) {
  204. return participantID ? getParticipantById(stateful, participantID) : getLocalParticipant(stateful);
  205. }
  206. /**
  207. * Returns a count of the known participants in the passed in redux state,
  208. * excluding any fake participants.
  209. *
  210. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  211. * {@code getState} function to be used to retrieve the state
  212. * features/base/participants.
  213. * @returns {number}
  214. */
  215. export function getParticipantCount(stateful: IStateful) {
  216. const state = toState(stateful);
  217. const {
  218. local,
  219. remote,
  220. fakeParticipants,
  221. sortedRemoteVirtualScreenshareParticipants
  222. } = state['features/base/participants'];
  223. return remote.size - fakeParticipants.size - sortedRemoteVirtualScreenshareParticipants.size + (local ? 1 : 0);
  224. }
  225. /**
  226. * Returns participant ID of the owner of a virtual screenshare participant.
  227. *
  228. * @param {string} id - The ID of the virtual screenshare participant.
  229. * @private
  230. * @returns {(string|undefined)}
  231. */
  232. export function getVirtualScreenshareParticipantOwnerId(id: string) {
  233. return id.split('-')[0];
  234. }
  235. /**
  236. * Returns the Map with fake participants.
  237. *
  238. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  239. * {@code getState} function to be used to retrieve the state
  240. * features/base/participants.
  241. * @returns {Map<string, IParticipant>} - The Map with fake participants.
  242. */
  243. export function getFakeParticipants(stateful: IStateful) {
  244. return toState(stateful)['features/base/participants'].fakeParticipants;
  245. }
  246. /**
  247. * Returns whether the fake participant is Jigasi.
  248. *
  249. * @param {IParticipant|undefined} participant - The participant entity.
  250. * @returns {boolean} - True if it's a Jigasi participant.
  251. */
  252. function isJigasiParticipant(participant?: IParticipant): boolean {
  253. return participant?.fakeParticipant === FakeParticipant.Jigasi;
  254. }
  255. /**
  256. * Returns whether the fake participant is a local screenshare.
  257. *
  258. * @param {IParticipant|undefined} participant - The participant entity.
  259. * @returns {boolean} - True if it's a local screenshare participant.
  260. */
  261. export function isLocalScreenshareParticipant(participant?: IParticipant): boolean {
  262. return participant?.fakeParticipant === FakeParticipant.LocalScreenShare;
  263. }
  264. /**
  265. * Returns whether the fake participant is a remote screenshare.
  266. *
  267. * @param {IParticipant|undefined} participant - The participant entity.
  268. * @returns {boolean} - True if it's a remote screenshare participant.
  269. */
  270. export function isRemoteScreenshareParticipant(participant?: IParticipant): boolean {
  271. return participant?.fakeParticipant === FakeParticipant.RemoteScreenShare;
  272. }
  273. /**
  274. * Returns whether the fake participant is of local or virtual screenshare type.
  275. *
  276. * @param {IReduxState} state - The (whole) redux state, or redux's.
  277. * @param {string|undefined} participantId - The participant id.
  278. * @returns {boolean} - True if it's one of the two.
  279. */
  280. export function isScreenShareParticipantById(state: IReduxState, participantId?: string): boolean {
  281. const participant = getParticipantByIdOrUndefined(state, participantId);
  282. return isScreenShareParticipant(participant);
  283. }
  284. /**
  285. * Returns whether the fake participant is of local or virtual screenshare type.
  286. *
  287. * @param {IParticipant|undefined} participant - The participant entity.
  288. * @returns {boolean} - True if it's one of the two.
  289. */
  290. export function isScreenShareParticipant(participant?: IParticipant): boolean {
  291. return isLocalScreenshareParticipant(participant) || isRemoteScreenshareParticipant(participant);
  292. }
  293. /**
  294. * Returns whether the (fake) participant is a shared video.
  295. *
  296. * @param {IParticipant|undefined} participant - The participant entity.
  297. * @returns {boolean} - True if it's a shared video participant.
  298. */
  299. export function isSharedVideoParticipant(participant?: IParticipant): boolean {
  300. return participant?.fakeParticipant === FakeParticipant.SharedVideo;
  301. }
  302. /**
  303. * Returns whether the fake participant is a whiteboard.
  304. *
  305. * @param {IParticipant|undefined} participant - The participant entity.
  306. * @returns {boolean} - True if it's a whiteboard participant.
  307. */
  308. export function isWhiteboardParticipant(participant?: IParticipant): boolean {
  309. return participant?.fakeParticipant === FakeParticipant.Whiteboard;
  310. }
  311. /**
  312. * Returns a count of the known remote participants in the passed in redux state.
  313. *
  314. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  315. * {@code getState} function to be used to retrieve the state
  316. * features/base/participants.
  317. * @returns {number}
  318. */
  319. export function getRemoteParticipantCount(stateful: IStateful) {
  320. const state = toState(stateful);
  321. const participantsState = state['features/base/participants'];
  322. return participantsState.remote.size - participantsState.sortedRemoteVirtualScreenshareParticipants.size;
  323. }
  324. /**
  325. * Returns a count of the known participants in the passed in redux state,
  326. * including fake participants.
  327. *
  328. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  329. * {@code getState} function to be used to retrieve the state
  330. * features/base/participants.
  331. * @returns {number}
  332. */
  333. export function getParticipantCountWithFake(stateful: IStateful) {
  334. const state = toState(stateful);
  335. const { local, localScreenShare, remote } = state['features/base/participants'];
  336. return remote.size + (local ? 1 : 0) + (localScreenShare ? 1 : 0);
  337. }
  338. /**
  339. * Returns participant's display name.
  340. *
  341. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
  342. * retrieve the state.
  343. * @param {string} id - The ID of the participant's display name to retrieve.
  344. * @returns {string}
  345. */
  346. export function getParticipantDisplayName(stateful: IStateful, id: string): string {
  347. const state = toState(stateful);
  348. const participant = getParticipantById(state, id);
  349. const {
  350. defaultLocalDisplayName,
  351. defaultRemoteDisplayName
  352. } = state['features/base/config'];
  353. if (participant) {
  354. if (isScreenShareParticipant(participant)) {
  355. return getScreenshareParticipantDisplayName(state, id);
  356. }
  357. if (participant.name) {
  358. return participant.name;
  359. }
  360. if (participant.local) {
  361. return defaultLocalDisplayName ?? '';
  362. }
  363. }
  364. return defaultRemoteDisplayName ?? '';
  365. }
  366. /**
  367. * Returns screenshare participant's display name.
  368. *
  369. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
  370. * retrieve the state.
  371. * @param {string} id - The ID of the screenshare participant's display name to retrieve.
  372. * @returns {string}
  373. */
  374. export function getScreenshareParticipantDisplayName(stateful: IStateful, id: string) {
  375. const ownerDisplayName = getParticipantDisplayName(stateful, getVirtualScreenshareParticipantOwnerId(id));
  376. return i18next.t('screenshareDisplayName', { name: ownerDisplayName });
  377. }
  378. /**
  379. * Returns a list of IDs of the participants that are currently screensharing.
  380. *
  381. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
  382. * retrieve the state.
  383. * @returns {Array<string>}
  384. */
  385. export function getScreenshareParticipantIds(stateful: IStateful): Array<string> {
  386. return toState(stateful)['features/base/tracks']
  387. .filter(track => track.videoType === VIDEO_TYPE.DESKTOP && !track.muted)
  388. .map(t => t.participantId);
  389. }
  390. /**
  391. * Returns the presence status of a participant associated with the passed id.
  392. *
  393. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  394. * {@code getState} function to be used to retrieve the state.
  395. * @param {string} id - The id of the participant.
  396. * @returns {string} - The presence status.
  397. */
  398. export function getParticipantPresenceStatus(stateful: IStateful, id: string) {
  399. if (!id) {
  400. return undefined;
  401. }
  402. const participantById = getParticipantById(stateful, id);
  403. if (!participantById) {
  404. return undefined;
  405. }
  406. return participantById.presence;
  407. }
  408. /**
  409. * Selectors for getting all remote participants.
  410. *
  411. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  412. * {@code getState} function to be used to retrieve the state
  413. * features/base/participants.
  414. * @returns {Map<string, Object>}
  415. */
  416. export function getRemoteParticipants(stateful: IStateful): Map<string, IParticipant> {
  417. return toState(stateful)['features/base/participants'].remote;
  418. }
  419. /**
  420. * Selectors for the getting the remote participants in the order that they are displayed in the filmstrip.
  421. *
  422. @param {(Function|Object)} stateful - The (whole) redux state, or redux's {@code getState} function to be used to
  423. * retrieve the state features/filmstrip.
  424. * @returns {Array<string>}
  425. */
  426. export function getRemoteParticipantsSorted(stateful: IStateful) {
  427. return toState(stateful)['features/filmstrip'].remoteParticipants;
  428. }
  429. /**
  430. * Returns the participant which has its pinned state set to truthy.
  431. *
  432. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  433. * {@code getState} function to be used to retrieve the state
  434. * features/base/participants.
  435. * @returns {(IParticipant|undefined)}
  436. */
  437. export function getPinnedParticipant(stateful: IStateful) {
  438. const state = toState(stateful);
  439. const { pinnedParticipant } = state['features/base/participants'];
  440. const stageFilmstrip = isStageFilmstripAvailable(state);
  441. if (stageFilmstrip) {
  442. const { activeParticipants } = state['features/filmstrip'];
  443. const id = activeParticipants.find(p => p.pinned)?.participantId;
  444. return id ? getParticipantById(stateful, id) : undefined;
  445. }
  446. if (!pinnedParticipant) {
  447. return undefined;
  448. }
  449. return getParticipantById(stateful, pinnedParticipant);
  450. }
  451. /**
  452. * Returns true if the participant is a moderator.
  453. *
  454. * @param {string} participant - Participant object.
  455. * @returns {boolean}
  456. */
  457. export function isParticipantModerator(participant?: IParticipant) {
  458. return participant?.role === PARTICIPANT_ROLE.MODERATOR;
  459. }
  460. /**
  461. * Returns the dominant speaker participant.
  462. *
  463. * @param {(Function|Object)} stateful - The (whole) redux state or redux's
  464. * {@code getState} function to be used to retrieve the state features/base/participants.
  465. * @returns {IParticipant} - The participant from the redux store.
  466. */
  467. export function getDominantSpeakerParticipant(stateful: IStateful) {
  468. const state = toState(stateful)['features/base/participants'];
  469. const { dominantSpeaker } = state;
  470. if (!dominantSpeaker) {
  471. return undefined;
  472. }
  473. return getParticipantById(stateful, dominantSpeaker);
  474. }
  475. /**
  476. * Returns true if all of the meeting participants are moderators.
  477. *
  478. * @param {Object|Function} stateful -Object or function that can be resolved
  479. * to the Redux state.
  480. * @returns {boolean}
  481. */
  482. export function isEveryoneModerator(stateful: IStateful) {
  483. const state = toState(stateful)['features/base/participants'];
  484. return state.everyoneIsModerator === true;
  485. }
  486. /**
  487. * Checks a value and returns true if it's a preloaded icon object.
  488. *
  489. * @param {?string | ?Object} icon - The icon to check.
  490. * @returns {boolean}
  491. */
  492. export function isIconUrl(icon?: string | Object) {
  493. return Boolean(icon) && (typeof icon === 'object' || typeof icon === 'function');
  494. }
  495. /**
  496. * Returns true if the current local participant is a moderator in the
  497. * conference.
  498. *
  499. * @param {Object|Function} stateful - Object or function that can be resolved
  500. * to the Redux state.
  501. * @returns {boolean}
  502. */
  503. export function isLocalParticipantModerator(stateful: IStateful) {
  504. const state = toState(stateful)['features/base/participants'];
  505. const { local } = state;
  506. if (!local) {
  507. return false;
  508. }
  509. return isParticipantModerator(local);
  510. }
  511. /**
  512. * Resolves the first loadable avatar URL for a participant.
  513. *
  514. * @param {Object} participant - The participant to resolve avatars for.
  515. * @param {Store} store - Redux store.
  516. * @returns {?string}
  517. */
  518. async function _getFirstLoadableAvatarUrl(participant: IParticipant, store: IStore) {
  519. for (let i = 0; i < AVATAR_CHECKER_FUNCTIONS.length; i++) {
  520. const url = AVATAR_CHECKER_FUNCTIONS[i](participant, store);
  521. if (url !== null) {
  522. if (AVATAR_CHECKED_URLS.has(url)) {
  523. const { isLoadable, isUsingCORS } = AVATAR_CHECKED_URLS.get(url) || {};
  524. if (isLoadable) {
  525. return {
  526. isUsingCORS,
  527. src: url
  528. };
  529. }
  530. } else {
  531. try {
  532. const { corsAvatarURLs } = store.getState()['features/base/config'];
  533. const useCORS = isIconUrl(url) ? false : isCORSAvatarURL(url, corsAvatarURLs);
  534. const { isUsingCORS, src } = await preloadImage(url, useCORS);
  535. AVATAR_CHECKED_URLS.set(src, {
  536. isLoadable: true,
  537. isUsingCORS
  538. });
  539. return {
  540. isUsingCORS,
  541. src
  542. };
  543. } catch (e) {
  544. AVATAR_CHECKED_URLS.set(url, {
  545. isLoadable: false,
  546. isUsingCORS: false
  547. });
  548. }
  549. }
  550. }
  551. }
  552. return undefined;
  553. }
  554. /**
  555. * Get the participants queue with raised hands.
  556. *
  557. * @param {(Function|Object)} stateful - The (whole) redux state, or redux's
  558. * {@code getState} function to be used to retrieve the state
  559. * features/base/participants.
  560. * @returns {Array<Object>}
  561. */
  562. export function getRaiseHandsQueue(stateful: IStateful): Array<{ id: string; raisedHandTimestamp: number; }> {
  563. const { raisedHandsQueue } = toState(stateful)['features/base/participants'];
  564. return raisedHandsQueue;
  565. }
  566. /**
  567. * Returns whether the given participant has his hand raised or not.
  568. *
  569. * @param {Object} participant - The participant.
  570. * @returns {boolean} - Whether participant has raise hand or not.
  571. */
  572. export function hasRaisedHand(participant?: IParticipant): boolean {
  573. return Boolean(participant?.raisedHandTimestamp);
  574. }