fix: improve chat message deduplication, add conversation refresh logic, and update UI components for consistency
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user