fix avatar click for closed group generated avatar

pull/1592/head
Audric Ackermann 4 years ago
parent aa58d3fdbe
commit 51e95bb16a
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -44,14 +44,22 @@ const NoImage = (props: {
name?: string; name?: string;
pubkey?: string; pubkey?: string;
size: AvatarSize; size: AvatarSize;
onAvatarClick?: () => void;
}) => { }) => {
const { memberAvatars, size } = props; const { name, memberAvatars, size, pubkey } = props;
// if no image but we have conversations set for the group, renders group members avatars // if no image but we have conversations set for the group, renders group members avatars
if (memberAvatars) { if (memberAvatars) {
return <ClosedGroupAvatar size={size} memberAvatars={memberAvatars} i18n={window.i18n} />; return (
<ClosedGroupAvatar
size={size}
memberAvatars={memberAvatars}
i18n={window.i18n}
onAvatarClick={props.onAvatarClick}
/>
);
} }
return <Identicon {...props} />; return <Identicon size={size} name={name} pubkey={pubkey} />;
}; };
const AvatarImage = (props: { const AvatarImage = (props: {
@ -87,11 +95,10 @@ export const Avatar = (props: Props) => {
setImageBroken(true); setImageBroken(true);
}; };
const isClosedGroupAvatar = memberAvatars && memberAvatars.length; const isClosedGroupAvatar = Boolean(memberAvatars?.length);
const hasImage = (base64Data || urlToLoad) && !imageBroken && !isClosedGroupAvatar; const hasImage = (base64Data || urlToLoad) && !imageBroken && !isClosedGroupAvatar;
const isClickable = !!props.onAvatarClick; const isClickable = !!props.onAvatarClick;
return ( return (
<div <div
className={classNames( className={classNames(

@ -7,6 +7,7 @@ interface Props {
size: number; size: number;
memberAvatars: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails memberAvatars: Array<ConversationAvatar>; // this is added by usingClosedConversationDetails
i18n: LocalizerType; i18n: LocalizerType;
onAvatarClick?: () => void;
} }
export class ClosedGroupAvatar extends React.PureComponent<Props> { export class ClosedGroupAvatar extends React.PureComponent<Props> {
@ -29,7 +30,7 @@ export class ClosedGroupAvatar extends React.PureComponent<Props> {
} }
public render() { public render() {
const { memberAvatars, size } = this.props; const { memberAvatars, size, onAvatarClick } = this.props;
const avatarsDiameter = this.getClosedGroupAvatarsSize(size); const avatarsDiameter = this.getClosedGroupAvatarsSize(size);
const conv1 = memberAvatars.length > 0 ? memberAvatars[0] : undefined; const conv1 = memberAvatars.length > 0 ? memberAvatars[0] : undefined;
@ -45,12 +46,14 @@ export class ClosedGroupAvatar extends React.PureComponent<Props> {
name={name1} name={name1}
size={avatarsDiameter} size={avatarsDiameter}
pubkey={conv1?.id} pubkey={conv1?.id}
onAvatarClick={onAvatarClick}
/> />
<Avatar <Avatar
avatarPath={conv2?.avatarPath} avatarPath={conv2?.avatarPath}
name={name2} name={name2}
size={avatarsDiameter} size={avatarsDiameter}
pubkey={conv2?.id} pubkey={conv2?.id}
onAvatarClick={onAvatarClick}
/> />
</div> </div>
); );

Loading…
Cancel
Save