File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { MiniProfile } from '../forms/MiniProfile';
44import UserIcon from '../icons/UserIcon' ;
55import * as ContextMenu from '@radix-ui/react-context-menu' ;
66import { useSupabaseClient , useUser } from '@supabase/auth-helpers-react' ;
7- import { removeFriendOrRequest , sendFriendRequest } from '@/services/friends.service' ;
7+ import { acceptFriendRequest , removeFriendOrRequest , sendFriendRequest } from '@/services/friends.service' ;
88import { useRelations } from '@/lib/store' ;
99
1010export function MessageHeader ( {
@@ -76,6 +76,16 @@ export function MessageHeader({
7676 >
7777 Send friend request
7878 </ ContextMenu . Item >
79+ < ContextMenu . Item
80+ className = 'ContextMenuItem'
81+ onClick = { ( ) => {
82+ // NOTE: Since this is only shown if a relation exists, therefore we can assume relation is not undefined
83+ acceptFriendRequest ( supabase , relation ! . id ) ;
84+ } }
85+ hidden = { ! relation || relation . relationship !== 'friend_requested' || relation . initiator_profile_id === currentUser ?. id }
86+ >
87+ Accept friend request
88+ </ ContextMenu . Item >
7989 < ContextMenu . Item
8090 className = 'ContextMenuItem'
8191 onClick = { ( ) => {
@@ -84,7 +94,11 @@ export function MessageHeader({
8494 } }
8595 hidden = { ! relation }
8696 >
87- { relation && relation . relationship === 'friend_requested' ? 'Cancel friend request' : 'Remove friend' }
97+ {
98+ relation && relation . relationship === 'friend_requested' ?
99+ ( relation . initiator_profile_id === currentUser ?. id ? 'Cancel friend request' : 'Reject friend request' )
100+ : 'Remove friend'
101+ }
88102 </ ContextMenu . Item >
89103 </ ContextMenu . Content >
90104 ) }
You can’t perform that action at this time.
0 commit comments