Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

functions.js 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // @flow
  2. import { getRoomName } from '../base/conference';
  3. import { getDialOutStatusUrl, getDialOutUrl } from '../base/config/functions';
  4. import { isAudioMuted, isVideoMutedByUser } from '../base/media';
  5. /**
  6. * Selector for the visibility of the 'join by phone' button.
  7. *
  8. * @param {Object} state - The state of the app.
  9. * @returns {boolean}
  10. */
  11. export function isJoinByPhoneButtonVisible(state: Object): boolean {
  12. return Boolean(getDialOutUrl(state) && getDialOutStatusUrl(state));
  13. }
  14. /**
  15. * Selector for determining if the device status strip is visible or not.
  16. *
  17. * @param {Object} state - The state of the app.
  18. * @returns {boolean}
  19. */
  20. export function isDeviceStatusVisible(state: Object): boolean {
  21. return !(isAudioMuted(state) && isVideoMutedByUser(state))
  22. && !state['features/base/config'].startSilent;
  23. }
  24. /**
  25. * Returns the text for the prejoin status bar.
  26. *
  27. * @param {Object} state - The state of the app.
  28. * @returns {string}
  29. */
  30. export function getDeviceStatusText(state: Object): string {
  31. return state['features/prejoin']?.deviceStatusText;
  32. }
  33. /**
  34. * Returns the type of the prejoin status bar: 'ok'|'warning'.
  35. *
  36. * @param {Object} state - The state of the app.
  37. * @returns {string}
  38. */
  39. export function getDeviceStatusType(state: Object): string {
  40. return state['features/prejoin']?.deviceStatusType;
  41. }
  42. /**
  43. * Returns the 'conferenceUrl' used for dialing out.
  44. *
  45. * @param {Object} state - The state of the app.
  46. * @returns {string}
  47. */
  48. export function getDialOutConferenceUrl(state: Object): string {
  49. return `${getRoomName(state)}@${state['features/base/config'].hosts.muc}`;
  50. }
  51. /**
  52. * Selector for getting the dial out country.
  53. *
  54. * @param {Object} state - The state of the app.
  55. * @returns {Object}
  56. */
  57. export function getDialOutCountry(state: Object): Object {
  58. return state['features/prejoin'].dialOutCountry;
  59. }
  60. /**
  61. * Selector for getting the dial out number (without prefix).
  62. *
  63. * @param {Object} state - The state of the app.
  64. * @returns {string}
  65. */
  66. export function getDialOutNumber(state: Object): string {
  67. return state['features/prejoin'].dialOutNumber;
  68. }
  69. /**
  70. * Selector for getting the dial out status while calling.
  71. *
  72. * @param {Object} state - The state of the app.
  73. * @returns {string}
  74. */
  75. export function getDialOutStatus(state: Object): string {
  76. return state['features/prejoin'].dialOutStatus;
  77. }
  78. /**
  79. * Returns the full dial out number (containing country code and +).
  80. *
  81. * @param {Object} state - The state of the app.
  82. * @returns {string}
  83. */
  84. export function getFullDialOutNumber(state: Object): string {
  85. const dialOutNumber = getDialOutNumber(state);
  86. const country = getDialOutCountry(state);
  87. return `+${country.dialCode}${dialOutNumber}`;
  88. }
  89. /**
  90. * Selector for getting the error if any while creating streams.
  91. *
  92. * @param {Object} state - The state of the app.
  93. * @returns {string}
  94. */
  95. export function getRawError(state: Object): string {
  96. return state['features/prejoin']?.rawError;
  97. }
  98. /**
  99. * Selector for getting the visiblity state for the 'JoinByPhoneDialog'.
  100. *
  101. * @param {Object} state - The state of the app.
  102. * @returns {boolean}
  103. */
  104. export function isJoinByPhoneDialogVisible(state: Object): boolean {
  105. return state['features/prejoin']?.showJoinByPhoneDialog;
  106. }
  107. /**
  108. * Returns true if the prejoin page is enabled and no flag
  109. * to bypass showing the page is present.
  110. *
  111. * @param {Object} state - The state of the app.
  112. * @returns {boolean}
  113. */
  114. export function isPrejoinPageEnabled(state: Object): boolean {
  115. return navigator.product !== 'ReactNative'
  116. && state['features/base/config'].prejoinPageEnabled
  117. && !state['features/base/settings'].userSelectedSkipPrejoin;
  118. }
  119. /**
  120. * Returns true if the prejoin page is visible & active.
  121. *
  122. * @param {Object} state - The state of the app.
  123. * @returns {boolean}
  124. */
  125. export function isPrejoinPageVisible(state: Object): boolean {
  126. return isPrejoinPageEnabled(state) && state['features/prejoin']?.showPrejoin;
  127. }