Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

CalleeInfo.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // @flow
  2. import React, { Component } from 'react';
  3. import { MEDIA_TYPE } from '../../../base/media';
  4. import {
  5. Avatar,
  6. getAvatarURL,
  7. getParticipants,
  8. getParticipantDisplayName,
  9. getParticipantPresenceStatus
  10. } from '../../../base/participants';
  11. import { Container, Text } from '../../../base/react';
  12. import { connect } from '../../../base/redux';
  13. import { isLocalTrackMuted } from '../../../base/tracks';
  14. import { CALLING, PresenceLabel } from '../../../presence-status';
  15. import styles from './styles';
  16. /**
  17. * The type of the React {@code Component} props of {@link CalleeInfo}.
  18. */
  19. type Props = {
  20. /**
  21. * The callee's information such as avatar and display name.
  22. */
  23. _callee: Object,
  24. _isVideoMuted: boolean
  25. };
  26. /**
  27. * Implements a React {@link Component} which depicts the establishment of a
  28. * call with a specific remote callee.
  29. *
  30. * @extends Component
  31. */
  32. class CalleeInfo extends Component<Props> {
  33. /**
  34. * Implements React's {@link Component#render()}.
  35. *
  36. * @inheritdoc
  37. * @returns {ReactElement}
  38. */
  39. render() {
  40. const {
  41. avatar,
  42. name,
  43. status = CALLING
  44. } = this.props._callee;
  45. const className = this.props._isVideoMuted ? 'solidBG' : undefined;
  46. return (
  47. <Container
  48. { ...this._style('ringing', className) }
  49. id = 'ringOverlay'>
  50. <Container
  51. { ...this._style('ringing__content') }>
  52. <Avatar
  53. { ...this._style('ringing__avatar') }
  54. uri = { avatar } />
  55. <Container { ...this._style('ringing__status') }>
  56. <PresenceLabel
  57. defaultPresence = { status }
  58. { ...this._style('ringing__text') } />
  59. </Container>
  60. <Container { ...this._style('ringing__name') }>
  61. <Text
  62. { ...this._style('ringing__text') }>
  63. { name }
  64. </Text>
  65. </Container>
  66. </Container>
  67. </Container>
  68. );
  69. }
  70. /**
  71. * Attempts to convert specified CSS class names into React
  72. * {@link Component} props {@code style} or {@code className}.
  73. *
  74. * @param {Array<string>} classNames - The CSS class names to convert
  75. * into React {@code Component} props {@code style} or {@code className}.
  76. * @returns {{
  77. * className: string,
  78. * style: Object
  79. * }}
  80. */
  81. _style(...classNames: Array<?string>) {
  82. let className = '';
  83. let style;
  84. for (const aClassName of classNames) {
  85. if (aClassName) {
  86. // Attemp to convert aClassName into style.
  87. if (styles && aClassName in styles) {
  88. // React Native will accept an Array as the value of the
  89. // style prop. However, I do not know about React.
  90. style = {
  91. ...style,
  92. ...styles[aClassName]
  93. };
  94. } else {
  95. // Otherwise, leave it as className.
  96. className += `${aClassName} `;
  97. }
  98. }
  99. }
  100. // Choose which of the className and/or style props has a value and,
  101. // consequently, must be returned.
  102. const props = {};
  103. if (className) {
  104. props.className = className.trim();
  105. }
  106. if (style) {
  107. props.style = style;
  108. }
  109. return props;
  110. }
  111. }
  112. /**
  113. * Maps (parts of) the redux state to {@code CalleeInfo}'s props.
  114. *
  115. * @param {Object} state - The redux state.
  116. * @private
  117. * @returns {{
  118. * _callee: Object
  119. * }}
  120. */
  121. function _mapStateToProps(state) {
  122. const _isVideoMuted
  123. = isLocalTrackMuted(state['features/base/tracks'], MEDIA_TYPE.VIDEO);
  124. const poltergeist
  125. = getParticipants(state).find(p => p.botType === 'poltergeist');
  126. if (poltergeist) {
  127. const { id } = poltergeist;
  128. return {
  129. _callee: {
  130. avatar: getAvatarURL(poltergeist),
  131. name: getParticipantDisplayName(state, id),
  132. status: getParticipantPresenceStatus(state, id)
  133. },
  134. _isVideoMuted
  135. };
  136. }
  137. return {
  138. _callee: state['features/invite'].initialCalleeInfo,
  139. _isVideoMuted
  140. };
  141. }
  142. export default connect(_mapStateToProps)(CalleeInfo);