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.3KB

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