Sync installed packages much more often

This commit is contained in:
franzap
2026-02-06 15:18:54 -03:00
parent dced962101
commit 83a74ceb01
2 changed files with 18 additions and 16 deletions
+13 -16
View File
@@ -126,11 +126,7 @@ final routerProvider = Provider<GoRouter>((ref) {
GoRoute(
path: '/profile',
builder: (context, state) => const ProfileScreen(),
routes: [
_appDetailRoute(),
_stackDetailRoute(),
_userRoute(),
],
routes: [_appDetailRoute(), _stackDetailRoute(), _userRoute()],
),
],
),
@@ -145,18 +141,19 @@ final routerProvider = Provider<GoRouter>((ref) {
final isUpdatesRoute = currentPath.startsWith('/updates');
final wasUpdatesRoute = previousPath?.startsWith('/updates') ?? false;
// Sync installed packages and refresh app data when navigating TO the updates branch
if (isUpdatesRoute && !wasUpdatesRoute) {
unawaited(
ref.read(packageManagerProvider.notifier).syncInstalledPackages().then((
_,
) {
// Trigger a recalculation of apps after sync
// (introduced after seeing cases of stale versions)
// 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
// This cleans up the "All done" state without affecting the count while visible
+5
View File
@@ -120,6 +120,11 @@ class UpdatePollerNotifier extends Notifier<UpdatePollerState> {
state = state.copyWith(isChecking: true);
try {
// Sync installed packages first so relay data is compared against
// fresh installed state (catches sideloads, external updates, etc.)
await ref
.read(packageManagerProvider.notifier)
.syncInstalledPackages();
await _fetchUpdatesFromRemote();
_hasCompletedFirstFetch = true;
state = state.copyWith(isChecking: false, lastCheckTime: DateTime.now());