useFetchConnectionStatus
Overview
TheuseFetchConnectionStatus hook allows you to check the connection status between the current logged-in user and another user. It returns detailed information about the connection state, including pending requests, established connections, and declined requests.
Usage Example
Advanced Usage with Dynamic UI
Usage for Connection Action Buttons
Parameters & Returns
Parameters
The hook returns a function that accepts an object with the following field:The ID of the user to check connection status with
Returns
The function returns a Promise that resolves to aConnectionStatusResponse object containing:
‘connected’ \
ID of the connection (if exists)
‘received’?`
ISO date when connection was established
ISO date when connection was requested
ISO date when the current state was created
ISO date when request was responded to
Connection Status Types
none
- No connection exists between the users
- Users can send connection requests
connected
- Users are mutually connected
- Includes
connectedAtandrequestedAttimestamps
pending
- A connection request is awaiting response
typeindicates if you sent (sent) or received (received) the request- Includes
createdAttimestamp
declined
- A connection request was declined
typeindicates if your request was declined (sent) or you declined theirs (received)- Includes
respondedAttimestamp
Error Handling
The hook will throw errors in the following cases:- No project is specified
- No user is logged in
- No user ID is provided
- Attempting to check connection status with yourself
Use Cases
This hook is essential for:- User profile pages to show appropriate connection actions
- Building dynamic connection buttons
- Connection management interfaces
- Social networking features
- Professional networking platforms
Related Hooks
useRequestConnection- Send connection requestsuseAcceptConnection- Accept connection requestsuseDeclineConnection- Decline connection requestsuseRemoveConnection- Remove connections or withdraw requestsuseConnectionManager- Comprehensive connection state management

