From 83a74ceb01dfe0aa1e400f3dbf56cfe9c576c9ea Mon Sep 17 00:00:00 2001 From: franzap <_@franzap.com> Date: Fri, 6 Feb 2026 15:18:54 -0300 Subject: [PATCH] Sync installed packages much more often --- lib/router.dart | 29 +++++++++++++---------------- lib/services/updates_service.dart | 5 +++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/router.dart b/lib/router.dart index 0d93ffd..757a15f 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -126,11 +126,7 @@ final routerProvider = Provider((ref) { GoRoute( path: '/profile', builder: (context, state) => const ProfileScreen(), - routes: [ - _appDetailRoute(), - _stackDetailRoute(), - _userRoute(), - ], + routes: [_appDetailRoute(), _stackDetailRoute(), _userRoute()], ), ], ), @@ -145,18 +141,19 @@ final routerProvider = Provider((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 diff --git a/lib/services/updates_service.dart b/lib/services/updates_service.dart index 8ebdb8f..8aabfaa 100644 --- a/lib/services/updates_service.dart +++ b/lib/services/updates_service.dart @@ -120,6 +120,11 @@ class UpdatePollerNotifier extends Notifier { 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());