fix avatar click for closed group generated avatar

This commit is contained in:
Audric Ackermann 2021-05-04 17:13:26 +10:00
parent aa58d3fdbe
commit 51e95bb16a
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4
2 changed files with 16 additions and 6 deletions

View File

@ -44,14 +44,22 @@ const NoImage = (props: {
name?: string;
pubkey?: string;
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 (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: {
@ -87,11 +95,10 @@ export const Avatar = (props: Props) => {
setImageBroken(true);
};
const isClosedGroupAvatar = memberAvatars && memberAvatars.length;
const isClosedGroupAvatar = Boolean(memberAvatars?.length);
const hasImage = (base64Data || urlToLoad) && !imageBroken && !isClosedGroupAvatar;
const isClickable = !!props.onAvatarClick;
return (
<div
className={classNames(

View File

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