Skip to content

Commit

Permalink
perf: Load patched apps as soon as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Dec 23, 2023
1 parent 85c8006 commit c94eb7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ class ManagerAPI {
);
}

Future<void> reAssessSavedApps() async {
Future<void> rePatchedSavedApps() async {
final List<PatchedApplication> patchedApps = getPatchedApps();

// Remove apps that are not installed anymore.
Expand Down
11 changes: 8 additions & 3 deletions lib/ui/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ class HomeViewModel extends BaseViewModel {
File? downloadedApk;

Future<void> 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'),
Expand All @@ -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) {
Expand All @@ -79,8 +86,6 @@ class HomeViewModel extends BaseViewModel {
_toast.showBottom('homeView.errorDownloadMessage');
}
}

_managerAPI.reAssessSavedApps().then((_) => _getPatchedApps());
}

void navigateToAppInfo(PatchedApplication app) {
Expand Down

0 comments on commit c94eb7a

Please sign in to comment.