FriendsPanel component provides a slide-out panel for managing social connections, including friends list, pending requests, and user search functionality.
Overview
This panel appears as a fixed sidebar on the right side of the screen, offering three tabs:- Friends: View all friends with online status and activity
- Requests: Manage incoming friend requests
- Add: Search for and send friend requests to new users
src/components/Social/FriendsPanel.tsx:20-411
Props
| Prop | Type | Description |
|---|---|---|
isOpen | boolean | Controls panel visibility |
onClose | () => void | Callback when panel is closed |
onOpenChat | (friend: Friend) => void | Opens chat window with friend |
onViewProfile | (friendId: string) => void | Opens friend profile view |
State Management
Core State
src/components/Social/FriendsPanel.tsx:28-36
Tab State
Three tabs control the active view:friends- Display all friends with online statusrequests- Show pending friend requestsadd- Search and add new friends
WebSocket Events
The component subscribes to real-time social events:friend_online
src/components/Social/FriendsPanel.tsx:47-55
friend_offline
src/components/Social/FriendsPanel.tsx:57-59
currently_watching
src/components/Social/FriendsPanel.tsx:61-70
friend_request / friend_accepted
src/components/Social/FriendsPanel.tsx:72-78
Data Loading
Load Friends and Requests
src/components/Social/FriendsPanel.tsx:89-100
Load Friends
src/components/Social/FriendsPanel.tsx:102-111
Load Requests
src/components/Social/FriendsPanel.tsx:113-121
User Search
Search functionality with minimum 2-character query:src/components/Social/FriendsPanel.tsx:123-139
Friend Request Management
Send Request
src/components/Social/FriendsPanel.tsx:141-150
Accept Request
src/components/Social/FriendsPanel.tsx:152-160
Reject Request
src/components/Social/FriendsPanel.tsx:162-169
UI Layout
Panel Structure
Fixed right sidebar with slide-in animation:src/components/Social/FriendsPanel.tsx:179-184
Header
Displays panel title with request badge:src/components/Social/FriendsPanel.tsx:187-195
Tab Navigation
Three-tab layout with request count indicator:src/components/Social/FriendsPanel.tsx:202-232
Friends Tab
Displays friends with online status separation:Online Friends Section
src/components/Social/FriendsPanel.tsx:252-266
All Friends Section
src/components/Social/FriendsPanel.tsx:270-293
Requests Tab
Displays pending friend requests with accept/reject buttons:src/components/Social/FriendsPanel.tsx:307-344
Add Friends Tab
Search interface with user results:Search Input
src/components/Social/FriendsPanel.tsx:351-359
Search Results
src/components/Social/FriendsPanel.tsx:365-390
FriendItem Component
Individual friend list item with online status and activity:src/components/Social/FriendsPanel.tsx:420-466
Error Handling
Displays error state with retry option:src/components/Social/FriendsPanel.tsx:236-248
Related Components
- ChatWindow - Chat UI component
- ProfileView - User profile display
API Functions
getFriends()- Retrieves friends list with online statusgetPendingRequests()- Retrieves incoming friend requestssearchUsers(query)- Searches for users by name or emailsendFriendRequest(userId)- Sends friend request to useracceptFriendRequest(fromId)- Accepts incoming friend requestrejectFriendRequest(fromId)- Rejects incoming friend requestonSocialEvent(eventType, handler)- Subscribes to WebSocket eventsformatRelativeTime(timestamp)- Formats timestamp as relative time