mirror of
https://github.com/revanced/revanced-manager.git
synced 2025-06-12 20:57:36 +02:00
fix: app listing on Home View
This commit is contained in:
@ -2,12 +2,14 @@ import 'dart:convert';
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:revanced_manager/app/app.locator.dart';
|
||||
import 'package:revanced_manager/models/patched_application.dart';
|
||||
import 'package:revanced_manager/services/github_api.dart';
|
||||
import 'package:revanced_manager/services/manager_api.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:stacked/stacked.dart';
|
||||
|
||||
@lazySingleton
|
||||
class HomeViewModel extends BaseViewModel {
|
||||
final GithubAPI githubAPI = GithubAPI();
|
||||
bool showUpdatableApps = true;
|
||||
|
||||
void toggleUpdatableApps(bool value) {
|
||||
@ -19,10 +21,20 @@ class HomeViewModel extends BaseViewModel {
|
||||
Future downloadIntegrations() => locator<ManagerAPI>().downloadIntegrations();
|
||||
|
||||
Future<List<PatchedApplication>> getPatchedApps(bool isUpdatable) async {
|
||||
List<PatchedApplication> list = [];
|
||||
SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||
List<String> patchedApps = prefs.getStringList('patchedApps') ?? [];
|
||||
return patchedApps
|
||||
.map((app) => PatchedApplication.fromJson(json.decode(app)))
|
||||
.toList();
|
||||
for (String str in patchedApps) {
|
||||
PatchedApplication app = PatchedApplication.fromJson(json.decode(str));
|
||||
bool hasUpdates = await githubAPI.hasUpdates(
|
||||
app,
|
||||
'revanced',
|
||||
'revanced-patches',
|
||||
);
|
||||
if (hasUpdates == isUpdatable) {
|
||||
list.add(app);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user