feat(group_chat): combined chats list with unread badges and live-update recovery - #726
feat(group_chat): combined chats list with unread badges and live-update recovery#726harshal-2304 wants to merge 3 commits into
Conversation
harshal-2304
commented
Sep 4, 2026
- Chats list — chat icon with green unread dot on the Connect app bar, plus a /chats screen: avatar, name, day label, Sender: message preview, unread badge. Group rooms only, sorted by recency.
- Live-update recovery — a foreground chat push for the open thread triggers a refetch, and replaces the socket if it turns up a message the socket never delivered. Fixes messages only appearing after leaving and re-entering the room.
- Mark read on send — sending moves last_read_at, so you no longer see your own message badged as unread after exiting.
|
| Filename | Overview |
|---|---|
| lib/features/group_chat/presentation/providers/chat_rooms_providers.dart | Adds shared paginated group-room state, but the previously reported filtered-page reachability and refresh/load-more race defects remain outstanding. |
| lib/features/group_chat/presentation/screens/group_chat_screen.dart | Adds push-backed thread recovery and mark-read-on-send, but the previously reported socket-health classification defects remain outstanding. |
| lib/features/group_chat/presentation/screens/chats_screen.dart | Adds the chats list and refresh UI, while its scroll-only pagination trigger contributes to the outstanding inability to reach group rooms behind filtered pages. |
| lib/features/group_chat/presentation/utils/chat_rooms_list.dart | Adds group filtering, ordering, unread, push-targeting, and preview helpers; its message-identity-free push targeting feeds the outstanding recovery ambiguity. |
| lib/features/connect/presentation/screens/connect_screen.dart | Adds the chats action and unread dot backed by the shared room provider. |
| lib/core/config/router/app_router.dart | Registers the new top-level chats screen route. |
| lib/core/config/router/app_routes.dart | Defines the /chats route constant. |
| lib/features/group_chat/presentation/widgets/chat_room_tile.dart | Renders group identity, date, message preview, avatar, and unread count for each chat row. |
| test/features/group_chat/presentation/utils/chat_rooms_list_test.dart | Covers the room-list utility behavior added by the PR. |
Sequence Diagram
sequenceDiagram
participant User
participant Connect
participant Rooms as Chat rooms provider
participant API
participant Thread as Group chat screen
participant Push
participant Socket
User->>Connect: Open community hub
Connect->>Rooms: Watch rooms and unread state
Rooms->>API: List chat rooms
API-->>Rooms: Mixed paginated rooms
Rooms-->>Connect: Group rooms and unread dot
User->>Thread: Open group chat
Socket-->>Thread: Live chat events
Push-->>Thread: Foreground chat push
Thread->>API: Refresh current thread
Thread->>Socket: Replace connection when recovery check indicates missed activity
Reviews (4): Last reviewed commit: "fix(group_chat): mark room as read immed..." | Re-trigger Greptile
| /// How many extra pages a single load will walk looking for group rooms. | ||
| static const int _emptyPageBudget = 5; |
There was a problem hiding this comment.
Filtered pagination stops early
If the server places the first group room after more than five consecutive direct-message-only pages, _pagePastDirectRooms exhausts this fixed budget while hasMore remains true. The empty screen has no scroll-driven loadMore path, so existing group chats and their unread indicator remain hidden.
Knowledge Base Used: Community connection and AI assistance
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/features/group_chat/presentation/providers/chat_rooms_providers.dart
Line: 89-90
Comment:
**Filtered pagination stops early**
If the server places the first group room after more than five consecutive direct-message-only pages, `_pagePastDirectRooms` exhausts this fixed budget while `hasMore` remains true. The empty screen has no scroll-driven `loadMore` path, so existing group chats and their unread indicator remain hidden.
**Knowledge Base Used:** [Community connection and AI assistance](https://app.greptile.com/webuddhist/-/custom-context/knowledge-base/openpecha/webuddhist-app/-/docs/community-connect-and-ai.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| void retry() { | ||
| if (state.rooms.isEmpty) { | ||
| loadInitial(); | ||
| } else { | ||
| loadMore(); | ||
| } |
There was a problem hiding this comment.
Retry strands pagination state
If the user retries while the automatic direct-room walk has a loadMore request in flight, loadInitial advances the generation without resetting isLoadingMore. The superseded request then returns without clearing that flag, permanently blocking later pagination and leaving deeper group rooms unreachable.
Knowledge Base Used: Community connection and AI assistance
Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/features/group_chat/presentation/providers/chat_rooms_providers.dart
Line: 227-232
Comment:
**Retry strands pagination state**
If the user retries while the automatic direct-room walk has a `loadMore` request in flight, `loadInitial` advances the generation without resetting `isLoadingMore`. The superseded request then returns without clearing that flag, permanently blocking later pagination and leaving deeper group rooms unreachable.
**Knowledge Base Used:** [Community connection and AI assistance](https://app.greptile.com/webuddhist/-/custom-context/knowledge-base/openpecha/webuddhist-app/-/docs/community-connect-and-ai.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.7d03fee to
2e97bc0
Compare
- Implemented group chat feature including chat rooms and messaging. - Added localization strings for multiple languages (Nepali, Chinese, Hindi, Mongolian, English). - Created new screens for displaying chat rooms and individual chat threads. - Introduced state management for chat rooms using Riverpod. - Added utility functions for managing chat room data and unread message indicators. - Developed UI components for chat room tiles and empty chat states. - Included tests for chat room functionalities and utilities.