From ff13c077088d1369a2b676da7aab7bb8187d44f2 Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Tue, 30 Sep 2025 14:35:05 +0530 Subject: [PATCH] refactor: migrate Phase 2 batch 1 - FutureProvider functions (1-4/15) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Migrated providers to @riverpod functions: - serverConfigsProvider → serverConfigs - activeServerProvider → activeServer - currentUserProvider → currentUser - modelsProvider → models All provider names unchanged. Code generation successful, no breaking changes. --- lib/core/providers/app_providers.dart | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/core/providers/app_providers.dart b/lib/core/providers/app_providers.dart index 70f157f..aa137d6 100644 --- a/lib/core/providers/app_providers.dart +++ b/lib/core/providers/app_providers.dart @@ -119,12 +119,14 @@ class LocaleNotifier extends Notifier { } // Server connection providers - optimized with caching -final serverConfigsProvider = FutureProvider>((ref) async { +@riverpod +Future> serverConfigs(ServerConfigsRef ref) async { final storage = ref.watch(optimizedStorageServiceProvider); return storage.getServerConfigs(); -}); +} -final activeServerProvider = FutureProvider((ref) async { +@riverpod +Future activeServer(ActiveServerRef ref) async { final storage = ref.watch(optimizedStorageServiceProvider); final configs = await ref.watch(serverConfigsProvider.future); final activeId = await storage.getActiveServerId(); @@ -138,7 +140,7 @@ final activeServerProvider = FutureProvider((ref) async { } return null; -}); +} final serverConnectionStateProvider = Provider((ref) { final activeServer = ref.watch(activeServerProvider); @@ -546,7 +548,8 @@ final apiTokenUpdaterProvider = Provider((ref) { }); }); -final currentUserProvider = FutureProvider((ref) async { +@riverpod +Future currentUser(CurrentUserRef ref) async { final api = ref.read(apiServiceProvider); final isAuthenticated = ref.watch(isAuthenticatedProvider2); @@ -557,7 +560,7 @@ final currentUserProvider = FutureProvider((ref) async { } catch (e) { return null; } -}); +} // Helper provider to force refresh auth state - now using unified system final refreshAuthStateProvider = Provider((ref) { @@ -567,7 +570,8 @@ final refreshAuthStateProvider = Provider((ref) { }); // Model providers -final modelsProvider = FutureProvider>((ref) async { +@riverpod +Future> models(ModelsRef ref) async { // Reviewer mode returns mock models final reviewerMode = ref.watch(reviewerModeProvider); if (reviewerMode) { @@ -613,7 +617,7 @@ final modelsProvider = FutureProvider>((ref) async { return []; } -}); +} @riverpod class SelectedModel extends _$SelectedModel {