jiti-meet/react/features/recent-list/components/RecentList.web.js

102 lines
2.3 KiB
JavaScript
Raw Normal View History

// @flow
2019-03-19 15:42:25 +00:00
import React from 'react';
2019-03-19 15:42:25 +00:00
import type { Dispatch } from 'redux';
import { translate } from '../../base/i18n';
import { MeetingsList } from '../../base/react';
2019-03-21 16:38:29 +00:00
import { connect } from '../../base/redux';
2020-05-20 10:57:03 +00:00
import { isRecentListEnabled, toDisplayableList } from '../functions';
import AbstractRecentList from './AbstractRecentList';
/**
* The type of the React {@code Component} props of {@link RecentList}
*/
type Props = {
/**
* Renders the list disabled.
*/
disabled: boolean,
/**
* The redux store's {@code dispatch} function.
*/
2019-03-19 15:42:25 +00:00
dispatch: Dispatch<any>,
/**
* The translate function.
*/
t: Function,
/**
* The recent list from the Redux store.
*/
_recentList: Array<Object>
};
/**
* The cross platform container rendering the list of the recently joined rooms.
*
*/
class RecentList extends AbstractRecentList<Props> {
_getRenderListEmptyComponent: () => React$Node;
_onPress: string => {};
/**
* Initializes a new {@code RecentList} instance.
*
* @inheritdoc
*/
constructor(props: Props) {
super(props);
this._getRenderListEmptyComponent
= this._getRenderListEmptyComponent.bind(this);
this._onPress = this._onPress.bind(this);
}
/**
* Implements the React Components's render method.
*
* @inheritdoc
*/
render() {
if (!isRecentListEnabled()) {
return null;
}
const {
disabled,
_recentList
} = this.props;
const recentList = toDisplayableList(_recentList);
return (
<MeetingsList
disabled = { disabled }
hideURL = { true }
listEmptyComponent = { this._getRenderListEmptyComponent() }
meetings = { recentList }
onPress = { this._onPress } />
);
}
}
/**
* Maps redux state to component props.
*
* @param {Object} state - The redux state.
* @returns {{
* _defaultServerURL: string,
* _recentList: Array
* }}
*/
export function _mapStateToProps(state: Object) {
return {
_recentList: state['features/recent-list']
};
}
export default translate(connect(_mapStateToProps)(RecentList));