// @flow import * as React from 'react'; import { Query } from 'react-apollo'; import { getUserByUsernameQuery, type GetUserType, } from 'shared/graphql/queries/user/getUser'; import { UserHoverProfile } from 'src/components/hoverProfile'; import AvatarImage from './image'; import { Container, AvatarLink } from './style'; import ConditionalWrap from 'src/components/conditionalWrap'; type HandlerProps = { user?: GetUserType, username?: string, size?: number, mobilesize?: number, style?: Object, showHoverProfile?: boolean, isClickable?: boolean, dataCy?: string, onlineBorderColor?: ?Function, }; type AvatarProps = { ...$Exact, user: GetUserType, }; const GetUserByUsername = (props: HandlerProps) => { const { username, showHoverProfile = true } = props; return ( {({ data }) => { if (!data || !data.user) return null; return ( ( )} > ); }} ); }; class Avatar extends React.Component { render() { const { user, dataCy, size = 32, mobilesize, style, isClickable = true, } = this.props; const src = user.profilePhoto; const userFallback = '/img/default_avatar.svg'; const source = [src, userFallback]; return ( ( )} > ); } } class AvatarHandler extends React.Component { render() { const { showHoverProfile = true, isClickable } = this.props; if (this.props.user) { const user = this.props.user; return ( ( )} > ); } if (!this.props.user && this.props.username) { return ( ); } return null; } } export default AvatarHandler;