jiti-meet/react/features/recent-list/components/AbstractRecentList.js

63 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-12-13 10:35:42 +00:00
// @flow
import { Component } from 'react';
import { appNavigate } from '../../app';
/**
2017-12-20 00:49:36 +00:00
* The type of the React {@code Component} props of {@link AbstractRecentList}
2017-12-13 10:35:42 +00:00
*/
2017-12-20 00:49:36 +00:00
type Props = {
2017-12-13 10:35:42 +00:00
/**
2017-12-20 00:49:36 +00:00
* The redux store's {@code dispatch} function.
2017-12-13 10:35:42 +00:00
*/
2017-12-20 00:49:36 +00:00
dispatch: Dispatch<*>
};
2017-12-13 10:35:42 +00:00
/**
2017-12-20 00:49:36 +00:00
* Implements a React {@link Component} which represents the list of conferences
* recently joined, similar to how a list of last dialed numbers list would do
* on a mobile device.
2017-12-13 10:35:42 +00:00
*
* @extends Component
*/
2018-01-17 11:19:10 +00:00
export default class AbstractRecentList extends Component<Props> {
2017-12-13 10:35:42 +00:00
/**
2017-12-20 00:49:36 +00:00
* Joins the selected room.
*
* @param {string} room - The selected room.
* @returns {void}
*/
_onJoin(room) {
room && this.props.dispatch(appNavigate(room));
2017-12-13 10:35:42 +00:00
}
/**
2017-12-20 00:49:36 +00:00
* Creates a bound onPress action for the list item.
*
* @param {string} room - The selected room.
* @returns {Function}
*/
_onSelect(room) {
return this._onJoin.bind(this, room);
2017-12-13 10:35:42 +00:00
}
}
2018-01-17 11:19:10 +00:00
/**
* Maps redux state to component props.
2018-01-17 11:19:10 +00:00
*
* @param {Object} state - The redux state.
* @returns {{
* _homeServer: string,
* _recentList: Array
* }}
*/
export function _mapStateToProps(state: Object) {
return {
_homeServer: state['features/app'].app._getDefaultURL(),
_recentList: state['features/recent-list'].list
};
}