Skip to content

Commit

Permalink
feat: filter apps by patch count
Browse files Browse the repository at this point in the history
  • Loading branch information
Ushie committed Dec 13, 2022
1 parent 01a681a commit d78868b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/services/patcher_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,14 @@ class PatcherAPI {
return filteredApps;
}

Future<List<Patch>> getFilteredPatches(String packageName) async {
List<Patch> getFilteredPatches(String packageName) {
List<Patch> 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);
}
}
Expand Down
6 changes: 4 additions & 2 deletions lib/ui/views/app_selector/app_selector_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -19,7 +18,10 @@ class AppSelectorViewModel extends BaseViewModel {

Future<void> 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();
}
Expand Down

0 comments on commit d78868b

Please sign in to comment.