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/updates_screen.dart';
|
||||||
import 'package:zapstore/screens/profile_screen.dart';
|
import 'package:zapstore/screens/profile_screen.dart';
|
||||||
import 'package:zapstore/services/package_manager/package_manager.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)
|
/// Root paths for each navigation branch (used for back navigation handling)
|
||||||
const kBranchRoots = ['/search', '/updates', '/profile'];
|
const kBranchRoots = ['/search', '/updates', '/profile'];
|
||||||
|
|
||||||
@@ -142,31 +140,18 @@ final routerProvider = Provider<GoRouter>((ref) {
|
|||||||
final wasUpdatesRoute = previousPath?.startsWith('/updates') ?? false;
|
final wasUpdatesRoute = previousPath?.startsWith('/updates') ?? false;
|
||||||
previousPath = currentPath;
|
previousPath = currentPath;
|
||||||
|
|
||||||
// Defer provider modifications to the next microtask. GoRouter's delegate
|
// Sync installed packages on every navigation to catch sideloads,
|
||||||
// can notify listeners synchronously during the widget tree build phase
|
// external installs/uninstalls, and self-updating apps.
|
||||||
// (e.g. on initial route resolution), and modifying StateNotifier state
|
// This is a local-only platform channel call (~100-500ms, no network).
|
||||||
// during build triggers a StateNotifierListenerError.
|
unawaited(
|
||||||
Future.microtask(() {
|
ref.read(packageManagerProvider.notifier).syncInstalledPackages(),
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Clear completed operations when navigating AWAY from updates
|
// Clear completed operations when navigating AWAY from updates
|
||||||
// This cleans up the "All done" state without affecting the count while visible
|
// This cleans up the "All done" state without affecting the count while visible
|
||||||
if (wasUpdatesRoute && !isUpdatesRoute) {
|
if (wasUpdatesRoute && !isUpdatesRoute) {
|
||||||
ref.read(packageManagerProvider.notifier).clearCompletedOperations();
|
ref.read(packageManagerProvider.notifier).clearCompletedOperations();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
router.routerDelegate.addListener(onRouteChange);
|
router.routerDelegate.addListener(onRouteChange);
|
||||||
|
|||||||
Reference in New Issue
Block a user