您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

RecentList.web.tsx 2.6KB

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