- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
feat: chat pagination #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| 
          
 Caution Review failedThe pull request is closed. WalkthroughThis pull request introduces message pagination with client-side loading, updates chat timestamps on message creation, refactors the backend chat query to use a single combined query with ordering by latest activity, reorganizes chat list UI layouts, and adds supporting Firestore indexes for efficient chat queries. Changes
 Sequence Diagram(s)sequenceDiagram
    participant User
    participant Frontend as Frontend<br/>(+page.svelte)
    participant Backend as Backend<br/>(ChatService)
    participant DB as Database
    User->>Frontend: Load messages (page 1)
    Frontend->>Backend: getUserChats(userId, page)
    Backend->>DB: Query chats with<br/>joins, grouping,<br/>ordering by latest msg
    DB-->>Backend: Return paginated<br/>chats + total count
    Backend->>Backend: Load full relations<br/>Sort by latest<br/>message timestamp
    Backend->>Backend: Augment with<br/>isRead flag per chat
    Backend-->>Frontend: Return chats +<br/>pagination metadata
    Frontend->>Frontend: Store pagination state<br/>(currentPage, totalPages)
    Frontend-->>User: Display chats +<br/>pagination controls
    User->>Frontend: Click Next page
    Frontend->>Backend: getUserChats(userId, page 2, append=true)
    Backend-->>Frontend: Return next batch
    Frontend->>Frontend: Append to messages
    Frontend-->>User: Update UI with<br/>combined chats
    sequenceDiagram
    participant User
    participant Frontend as Frontend<br/>(MessageService)
    participant ChatSvc as ChatService
    participant DB as Database
    User->>Frontend: Send message
    Frontend->>Frontend: Create Message record
    Frontend->>DB: Save Message
    DB-->>Frontend: Message saved
    Frontend->>ChatSvc: Update chat.updatedAt
    ChatSvc->>DB: Fetch Chat by ID
    DB-->>ChatSvc: Chat record
    ChatSvc->>ChatSvc: Set updatedAt<br/>to current time
    ChatSvc->>DB: Save Chat
    DB-->>ChatSvc: Chat updated
    ChatSvc-->>Frontend: Complete
    Frontend-->>User: Message sent
    Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes The changes span multiple domains (database configuration, backend services, frontend components, and pagination UI) with varying complexity. The backend ChatService refactoring introduces a new query pattern with explicit sorting logic, while frontend changes include state management and pagination controls. Layout adjustments are straightforward, but the heterogeneous nature of changes across services and components requires careful review of integration points and data flow consistency. Possibly related PRs
 Suggested reviewers
 Poem
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment   | 
    
Description of change
Issue Number
Type of change
How the change has been tested
Change checklist
Summary by CodeRabbit
New Features
Improvements