// @flow import React, { useCallback } from 'react'; import { translate } from '../../../base/i18n'; import { Icon, IconCloseLarge } from '../../../base/icons'; import { connect } from '../../../base/redux'; import { toggleChat } from '../../actions.web'; type Props = { /** * Function to be called when pressing the close button. */ onCancel: Function, /** * An optional class name. */ className: string, /** * Whether the polls feature is enabled or not. */ isPollsEnabled: boolean, /** * Invoked to obtain translated strings. */ t: Function }; /** * Custom header of the {@code ChatDialog}. * * @returns {React$Element} */ function Header({ onCancel, className, isPollsEnabled, t }: Props) { const onKeyPressHandler = useCallback(e => { if (onCancel && (e.key === ' ' || e.key === 'Enter')) { e.preventDefault(); onCancel(); } }, [ onCancel ]); return (
{ t(isPollsEnabled ? 'chat.titleWithPolls' : 'chat.title') }
); } const mapDispatchToProps = { onCancel: toggleChat }; export default translate(connect(null, mapDispatchToProps)(Header));