File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -13,15 +13,26 @@ import {
13
13
} from '../../../state/selectors/selectedConversation' ;
14
14
import { Avatar , AvatarSize } from '../../avatar/Avatar' ;
15
15
import { SessionIconButton } from '../../icon' ;
16
- import { useIsLegacyGroup } from '../../../hooks/useParamSelector' ;
16
+ import { useIsGroupV2 , useIsLegacyGroup } from '../../../hooks/useParamSelector' ;
17
+ import { useLibGroupInvitePending } from '../../../state/selectors/userGroups' ;
17
18
18
19
export const AvatarHeader = ( props : { pubkey : string ; onAvatarClick ?: ( ) => void } ) => {
19
20
const { pubkey, onAvatarClick } = props ;
20
21
const isApproved = useSelectedIsApproved ( ) ;
21
22
22
23
const isLegacyGroup = useIsLegacyGroup ( pubkey ) ;
24
+ const invitePending = useLibGroupInvitePending ( pubkey ) ;
25
+ const isPrivate = useSelectedIsPrivate ( ) ;
26
+ const isGroupV2 = useIsGroupV2 ( pubkey ) ;
27
+
28
+ const canClickLegacy = isLegacyGroup && false ; // we can never click the avatar if it's a legacy group
29
+ const canClickPrivateApproved = isApproved && isPrivate ; // we can only click the avatar if it's a private and approved conversation
30
+ const canClick03GroupAccepted = isGroupV2 && ! invitePending ; // we can only click the avatar if it's a group and have accepted the invite already
23
31
24
- const optOnAvatarClick = ! isLegacyGroup && isApproved ? onAvatarClick : undefined ;
32
+ const optOnAvatarClick =
33
+ canClickLegacy || canClickPrivateApproved || canClick03GroupAccepted
34
+ ? onAvatarClick
35
+ : undefined ;
25
36
26
37
return (
27
38
< span className = "module-conversation-header__avatar" >
Original file line number Diff line number Diff line change 3
3
useIsKickedFromGroup ,
4
4
useIsGroupDestroyed ,
5
5
useConversationUsername ,
6
+ useWeAreAdmin ,
6
7
} from '../../hooks/useParamSelector' ;
7
8
import {
8
9
showDeleteGroupByConvoId ,
@@ -16,6 +17,7 @@ export function useShowLeaveGroupCb(conversationId?: string) {
16
17
const isGroupDestroyed = useIsGroupDestroyed ( conversationId ) ;
17
18
const isMessageRequestShown = useIsMessageRequestOverlayShown ( ) ;
18
19
const username = useConversationUsername ( conversationId ) || conversationId ;
20
+ const weAreAdmin = useWeAreAdmin ( conversationId ) ;
19
21
20
22
// Note: if we are the only admin, leaving it will warn that it will actually delete it for everyone.
21
23
@@ -24,7 +26,8 @@ export function useShowLeaveGroupCb(conversationId?: string) {
24
26
isMessageRequestShown ||
25
27
isGroupDestroyed ||
26
28
isKickedFromGroup ||
27
- ! conversationId
29
+ ! conversationId ||
30
+ weAreAdmin
28
31
) {
29
32
return null ;
30
33
}
Original file line number Diff line number Diff line change @@ -262,7 +262,7 @@ export function useSelectedIsBlocked() {
262
262
263
263
export function useSelectedIsApproved ( ) {
264
264
return useSelector ( ( state : StateType ) : boolean => {
265
- return ! ! ( getSelectedConversation ( state ) ?. isApproved || false ) ;
265
+ return getSelectedConversation ( state ) ?. isApproved || false ;
266
266
} ) ;
267
267
}
268
268
You can’t perform that action at this time.
0 commit comments