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.

RecentList.web.js 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // @flow
  2. import React from 'react';
  3. import { connect } from 'react-redux';
  4. import { translate } from '../../base/i18n';
  5. import { MeetingsList } from '../../base/react';
  6. import AbstractRecentList from './AbstractRecentList';
  7. import { isRecentListEnabled, toDisplayableList } from '../functions';
  8. /**
  9. * The type of the React {@code Component} props of {@link RecentList}
  10. */
  11. type Props = {
  12. /**
  13. * Renders the list disabled.
  14. */
  15. disabled: boolean,
  16. /**
  17. * The redux store's {@code dispatch} function.
  18. */
  19. dispatch: Dispatch<*>,
  20. /**
  21. * The translate function.
  22. */
  23. t: Function,
  24. /**
  25. * The recent list from the Redux store.
  26. */
  27. _recentList: Array<Object>
  28. };
  29. /**
  30. * The cross platform container rendering the list of the recently joined rooms.
  31. *
  32. */
  33. class RecentList extends AbstractRecentList<Props> {
  34. _getRenderListEmptyComponent: () => React$Node;
  35. _onPress: string => {};
  36. /**
  37. * Initializes a new {@code RecentList} instance.
  38. *
  39. * @inheritdoc
  40. */
  41. constructor(props: Props) {
  42. super(props);
  43. this._getRenderListEmptyComponent
  44. = this._getRenderListEmptyComponent.bind(this);
  45. this._onPress = this._onPress.bind(this);
  46. }
  47. /**
  48. * Implements the React Components's render method.
  49. *
  50. * @inheritdoc
  51. */
  52. render() {
  53. if (!isRecentListEnabled()) {
  54. return null;
  55. }
  56. const {
  57. disabled,
  58. _recentList
  59. } = this.props;
  60. const recentList = toDisplayableList(_recentList);
  61. return (
  62. <MeetingsList
  63. disabled = { disabled }
  64. hideURL = { true }
  65. listEmptyComponent = { this._getRenderListEmptyComponent() }
  66. meetings = { recentList }
  67. onPress = { this._onPress } />
  68. );
  69. }
  70. }
  71. /**
  72. * Maps redux state to component props.
  73. *
  74. * @param {Object} state - The redux state.
  75. * @returns {{
  76. * _defaultServerURL: string,
  77. * _recentList: Array
  78. * }}
  79. */
  80. export function _mapStateToProps(state: Object) {
  81. return {
  82. _recentList: state['features/recent-list']
  83. };
  84. }
  85. export default translate(connect(_mapStateToProps)(RecentList));