From 6dd162dd4070b40cbed035f2c78c7bd39a2ff465 Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Fri, 6 Feb 2026 21:20:49 -0300 Subject: [PATCH] Remove useless provider invalidation --- lib/router.dart | 37 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/lib/router.dart b/lib/router.dart index 3e73141..0c1caed 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -12,8 +12,6 @@ import 'package:zapstore/screens/search_screen.dart'; import 'package:zapstore/screens/updates_screen.dart'; import 'package:zapstore/screens/profile_screen.dart'; import 'package:zapstore/services/package_manager/package_manager.dart'; -import 'package:zapstore/services/updates_service.dart'; - /// Root paths for each navigation branch (used for back navigation handling) const kBranchRoots = ['/search', '/updates', '/profile']; @@ -142,31 +140,18 @@ final routerProvider = Provider((ref) { final wasUpdatesRoute = previousPath?.startsWith('/updates') ?? false; previousPath = currentPath; - // Defer provider modifications to the next microtask. GoRouter's delegate - // can notify listeners synchronously during the widget tree build phase - // (e.g. on initial route resolution), and modifying StateNotifier state - // during build triggers a StateNotifierListenerError. - Future.microtask(() { - // Sync installed packages on every navigation to catch sideloads, - // external installs/uninstalls, and self-updating apps. - // This is a local-only platform channel call (~100-500ms, no network). - unawaited( - ref.read(packageManagerProvider.notifier).syncInstalledPackages().then(( - _, - ) { - // If on updates branch, trigger a recalculation of updates after sync - if (isUpdatesRoute) { - ref.invalidate(categorizedUpdatesProvider); - } - }), - ); + // Sync installed packages on every navigation to catch sideloads, + // external installs/uninstalls, and self-updating apps. + // This is a local-only platform channel call (~100-500ms, no network). + unawaited( + ref.read(packageManagerProvider.notifier).syncInstalledPackages(), + ); - // Clear completed operations when navigating AWAY from updates - // This cleans up the "All done" state without affecting the count while visible - if (wasUpdatesRoute && !isUpdatesRoute) { - ref.read(packageManagerProvider.notifier).clearCompletedOperations(); - } - }); + // Clear completed operations when navigating AWAY from updates + // This cleans up the "All done" state without affecting the count while visible + if (wasUpdatesRoute && !isUpdatesRoute) { + ref.read(packageManagerProvider.notifier).clearCompletedOperations(); + } } router.routerDelegate.addListener(onRouteChange);