fix: improve chat message deduplication, add conversation refresh logic, and update UI components for consistency

This commit is contained in:
pradeepkumar
2026-04-18 11:34:48 +05:30
parent 164d590d31
commit afa1f3489a
6 changed files with 47 additions and 8 deletions

View File

@@ -585,6 +585,24 @@ class MessagingNotifier extends StateNotifier<MessagingState> {
}
}
/// Refetch a single conversation — used when opening chat to get fresh
/// presence (isOnline/lastSeenAt) since the list may be stale. Mirrors
/// web's selectConversation which calls getConversation on open.
Future<void> refreshConversation(String conversationId) async {
try {
final fresh = await _repository.getConversation(conversationId);
if (!mounted) return;
final updated = state.conversations.map((c) {
return c.id == conversationId
? c.copyWith(otherParty: fresh.otherParty)
: c;
}).toList();
state = state.copyWith(conversations: updated);
} catch (_) {
// Non-fatal — existing cached data remains in place
}
}
Future<void> loadUnreadCount() async {
try {
final count = await _repository.getUnreadCount();