import React from 'react'; import { Avatar } from './Avatar'; declare global { interface Window { displayNameRegex: any; } } interface Props { i18n: any; profileName: string; avatarPath: string; avatarColor: string; pubkey: string; onClose: any; onStartConversation: any; } export class UserDetailsDialog extends React.Component { constructor(props: any) { super(props); this.closeDialog = this.closeDialog.bind(this); this.onKeyUp = this.onKeyUp.bind(this); this.onClickStartConversation = this.onClickStartConversation.bind(this); window.addEventListener('keyup', this.onKeyUp); } public render() { const i18n = this.props.i18n; const cancelText = i18n('cancel'); const startConversation = i18n('startConversation'); return (
{this.renderAvatar()} {this.props.profileName}
{this.props.pubkey}
); } private renderAvatar() { const avatarPath = this.props.avatarPath; const color = this.props.avatarColor; return ( ); } private onKeyUp(event: any) { switch (event.key) { case 'Enter': this.onClickStartConversation(); break; case 'Esc': case 'Escape': this.closeDialog(); break; default: } } private closeDialog() { window.removeEventListener('keyup', this.onKeyUp); this.props.onClose(); } private onClickStartConversation() { this.props.onStartConversation(); this.closeDialog(); } }