Skip to content

Commit c8ee6ac

Browse files
committed
fix: allow admins of communities to update avatar
1 parent 225bf9f commit c8ee6ac

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

ts/components/avatar/Avatar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ const NoImage = memo(
9393
}
9494
);
9595

96-
9796
const AvatarImage = (
9897
props: Pick<Props, 'base64Data' | 'dataTestId'> & {
9998
avatarPath?: string;

ts/components/conversation/header/ConversationHeaderItems.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
useSelectedIsNoteToSelf,
1111
useSelectedIsPrivate,
1212
useSelectedIsPrivateFriend,
13+
useSelectedIsPublic,
14+
useSelectedWeAreAdmin,
1315
} from '../../../state/selectors/selectedConversation';
1416
import { Avatar, AvatarSize } from '../../avatar/Avatar';
1517
import { SessionIconButton } from '../../icon';
@@ -25,12 +27,16 @@ export const AvatarHeader = (props: { pubkey: string; onAvatarClick?: () => void
2527
const isPrivate = useSelectedIsPrivate();
2628
const isGroupV2 = useIsGroupV2(pubkey);
2729

30+
const isPublic = useSelectedIsPublic();
31+
const weAreAdmin = useSelectedWeAreAdmin();
32+
2833
const canClickLegacy = isLegacyGroup && false; // we can never click the avatar if it's a legacy group
2934
const canClickPrivateApproved = isApproved && isPrivate; // we can only click the avatar if it's a private and approved conversation
3035
const canClick03GroupAccepted = isGroupV2 && !invitePending; // we can only click the avatar if it's a group and have accepted the invite already
36+
const canClickCommunity = isPublic && weAreAdmin;
3137

3238
const optOnAvatarClick =
33-
canClickLegacy || canClickPrivateApproved || canClick03GroupAccepted
39+
canClickLegacy || canClickPrivateApproved || canClick03GroupAccepted || canClickCommunity
3440
? onAvatarClick
3541
: undefined;
3642

ts/components/menuAndSettingsHooks/useEditProfilePictureCallback.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function useEditProfilePicture({ conversationId }: { conversationId: string }) {
1818

1919
const hasQAButtonsOn = hasClosedGroupV2QAButtons();
2020

21-
return isMe || ((isPublic || isGroup) && weAreAdmin && hasQAButtonsOn);
21+
return isMe || ((isPublic || (isGroup && hasQAButtonsOn)) && weAreAdmin);
2222
}
2323

2424
export function useEditProfilePictureCallback({ conversationId }: { conversationId: string }) {

0 commit comments

Comments
 (0)