mirror of
https://github.com/zapstore/zapstore.git
synced 2026-10-05 12:38:24 +00:00
Remove useless provider invalidation
This commit is contained in:
+11
-26
@@ -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<GoRouter>((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);
|
||||
|
||||
Reference in New Issue
Block a user