From c94eb7a48ee3db12bd5406a1566c3ca50f2daf71 Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 23 Dec 2023 23:48:02 +0100 Subject: [PATCH] perf: Load patched apps as soon as possible --- lib/services/manager_api.dart | 2 +- lib/ui/views/home/home_viewmodel.dart | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/services/manager_api.dart b/lib/services/manager_api.dart index 06d87f43..17072b04 100644 --- a/lib/services/manager_api.dart +++ b/lib/services/manager_api.dart @@ -632,7 +632,7 @@ class ManagerAPI { ); } - Future reAssessSavedApps() async { + Future rePatchedSavedApps() async { final List patchedApps = getPatchedApps(); // Remove apps that are not installed anymore. diff --git a/lib/ui/views/home/home_viewmodel.dart b/lib/ui/views/home/home_viewmodel.dart index c9356a56..e5448c5e 100644 --- a/lib/ui/views/home/home_viewmodel.dart +++ b/lib/ui/views/home/home_viewmodel.dart @@ -38,11 +38,16 @@ class HomeViewModel extends BaseViewModel { File? downloadedApk; Future initialize(BuildContext context) async { - _latestManagerVersion = await _managerAPI.getLatestManagerVersion(); + _managerAPI.rePatchedSavedApps().then((_) => _getPatchedApps()); + if (!_managerAPI.getPatchesConsent()) { await showPatchesConsent(context); } + + _latestManagerVersion = await _managerAPI.getLatestManagerVersion(); + await _patcherAPI.initialize(); + await flutterLocalNotificationsPlugin.initialize( const InitializationSettings( android: AndroidInitializationSettings('ic_notification'), @@ -63,11 +68,13 @@ class HomeViewModel extends BaseViewModel { .resolvePlatformSpecificImplementation< AndroidFlutterLocalNotificationsPlugin>() ?.requestNotificationsPermission(); + final bool isConnected = await Connectivity().checkConnectivity() != ConnectivityResult.none; if (!isConnected) { _toast.showBottom('homeView.noConnection'); } + final NotificationAppLaunchDetails? notificationAppLaunchDetails = await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails(); if (notificationAppLaunchDetails?.didNotificationLaunchApp ?? false) { @@ -79,8 +86,6 @@ class HomeViewModel extends BaseViewModel { _toast.showBottom('homeView.errorDownloadMessage'); } } - - _managerAPI.reAssessSavedApps().then((_) => _getPatchedApps()); } void navigateToAppInfo(PatchedApplication app) {