diff --git a/lib/services/patcher_api.dart b/lib/services/patcher_api.dart index c0f7d70e18..134f8053fd 100644 --- a/lib/services/patcher_api.dart +++ b/lib/services/patcher_api.dart @@ -94,15 +94,14 @@ class PatcherAPI { return filteredApps; } - Future> getFilteredPatches(String packageName) async { + List getFilteredPatches(String packageName) { List filteredPatches = []; _patches.forEach((patch) { if (patch.compatiblePackages.isEmpty) { filteredPatches.add(patch); } else { if (!patch.name.contains('settings') && - patch.compatiblePackages.any((pack) => pack.name == packageName) - ) { + patch.compatiblePackages.any((pack) => pack.name == packageName)) { filteredPatches.add(patch); } } diff --git a/lib/ui/views/app_selector/app_selector_viewmodel.dart b/lib/ui/views/app_selector/app_selector_viewmodel.dart index 6802a0efeb..b2205dd09e 100644 --- a/lib/ui/views/app_selector/app_selector_viewmodel.dart +++ b/lib/ui/views/app_selector/app_selector_viewmodel.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:device_apps/device_apps.dart'; import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; import 'package:revanced_manager/app/app.locator.dart'; import 'package:revanced_manager/models/patched_application.dart'; import 'package:revanced_manager/services/patcher_api.dart'; @@ -19,7 +18,10 @@ class AppSelectorViewModel extends BaseViewModel { Future initialize() async { apps.addAll(await _patcherAPI.getFilteredInstalledApps()); - apps.sort((a, b) => a.appName.compareTo(b.appName)); + apps.sort(((a, b) => _patcherAPI + .getFilteredPatches(b.packageName) + .length + .compareTo(_patcherAPI.getFilteredPatches(a.packageName).length))); noApps = apps.isEmpty; notifyListeners(); }