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

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