useFetchConnectionStatus
Overview
The useFetchConnectionStatus 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
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 a ConnectionStatusResponse object containing:
ID of the connection (if exists)
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
connectedAt and requestedAt timestamps
pending
- A connection request is awaiting response
type indicates if you sent (sent) or received (received) the request
- Includes
createdAt timestamp
declined
- A connection request was declined
type indicates if your request was declined (sent) or you declined theirs (received)
- Includes
respondedAt timestamp
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
useRequestConnection - Send connection requests
useAcceptConnection - Accept connection requests
useDeclineConnection - Decline connection requests
useRemoveConnection - Remove connections or withdraw requests
useConnectionManager - Comprehensive connection state management