refactor: centralize conversation cache management
- Introduced a new method `refreshConversationsCache` to streamline the invalidation of the conversations provider and optionally the folders provider. - Updated various components to utilize the new cache management method, enhancing code clarity and reducing redundancy. - This refactor improves the efficiency of conversation and folder synchronization across the application.
This commit is contained in:
@@ -236,7 +236,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
|
||||
// Force refresh conversations provider to ensure we get the demo conversations
|
||||
if (!mounted) return;
|
||||
ref.invalidate(conversationsProvider);
|
||||
refreshConversationsCache(ref);
|
||||
|
||||
// Try to load demo conversation
|
||||
for (int i = 0; i < 10; i++) {
|
||||
@@ -1486,7 +1486,7 @@ class _ChatPageState extends ConsumerState<ChatPage> {
|
||||
// Also refresh the conversations list to reconcile missed events
|
||||
// and keep timestamps/order in sync with the server.
|
||||
try {
|
||||
ref.invalidate(conversationsProvider);
|
||||
refreshConversationsCache(ref);
|
||||
// Best-effort await to stabilize UI; ignore errors.
|
||||
await ref.read(conversationsProvider.future);
|
||||
} catch (_) {}
|
||||
|
||||
Reference in New Issue
Block a user