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:
cogwheel0
2025-10-02 00:30:14 +05:30
parent 73ccb14b20
commit ff02af1e89
7 changed files with 122 additions and 68 deletions

View File

@@ -103,7 +103,7 @@ void _scheduleConversationWarmup(Ref ref, {bool force = false}) {
return;
}
if (existing.hasError) {
ref.invalidate(conversationsProvider);
refreshConversationsCache(ref);
}
final conversations = await ref.read(conversationsProvider.future);
statusController.set(_ConversationWarmupStatus.complete);
@@ -368,7 +368,7 @@ class _ForegroundRefreshObserver extends WidgetsBindingObserver {
// Schedule to avoid side-effects during build frames
Future.microtask(() {
try {
_ref.invalidate(conversationsProvider);
refreshConversationsCache(_ref);
_ref
.read(_conversationWarmupStatusProvider.notifier)
.set(_ConversationWarmupStatus.idle);