mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
feat: use github to get latest patches version if custom sources are used.
This commit is contained in:
parent
6e05120aa5
commit
b0c4567cb8
@ -130,4 +130,18 @@ class GithubAPI {
|
|||||||
}
|
}
|
||||||
return patches;
|
return patches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> getLastestReleaseVersion(String repoName) async {
|
||||||
|
try {
|
||||||
|
Map<String, dynamic>? release = await _getLatestRelease(repoName);
|
||||||
|
if (release != null) {
|
||||||
|
return release['tag_name'];
|
||||||
|
} else {
|
||||||
|
return 'Unknown';
|
||||||
|
}
|
||||||
|
} on Exception catch (e, s) {
|
||||||
|
await Sentry.captureException(e, stackTrace: s);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ import 'package:flutter_i18n/widgets/I18nText.dart';
|
|||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/models/patch.dart';
|
import 'package:revanced_manager/models/patch.dart';
|
||||||
import 'package:revanced_manager/models/patched_application.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:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:revanced_manager/services/patcher_api.dart';
|
import 'package:revanced_manager/services/patcher_api.dart';
|
||||||
import 'package:revanced_manager/services/toast.dart';
|
import 'package:revanced_manager/services/toast.dart';
|
||||||
@ -14,10 +15,14 @@ import 'package:flutter/material.dart';
|
|||||||
class PatchesSelectorViewModel extends BaseViewModel {
|
class PatchesSelectorViewModel extends BaseViewModel {
|
||||||
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
final PatcherAPI _patcherAPI = locator<PatcherAPI>();
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
||||||
|
final GithubAPI _githubAPI = locator<GithubAPI>();
|
||||||
final List<Patch> patches = [];
|
final List<Patch> patches = [];
|
||||||
final List<Patch> selectedPatches =
|
final List<Patch> selectedPatches =
|
||||||
locator<PatcherViewModel>().selectedPatches;
|
locator<PatcherViewModel>().selectedPatches;
|
||||||
String? patchesVersion = '';
|
String? patchesVersion = '';
|
||||||
|
bool isDefaultPatchesRepo() {
|
||||||
|
return _managerAPI.getPatchesRepo() == 'revanced/revanced-patches';
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
getPatchesVersion();
|
getPatchesVersion();
|
||||||
@ -104,9 +109,15 @@ class PatchesSelectorViewModel extends BaseViewModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String?> getPatchesVersion() async {
|
Future<String?> getPatchesVersion() async {
|
||||||
|
if (isDefaultPatchesRepo()) {
|
||||||
patchesVersion = await _managerAPI.getLatestPatchesVersion();
|
patchesVersion = await _managerAPI.getLatestPatchesVersion();
|
||||||
// print('Patches version: $patchesVersion');
|
// print('Patches version: $patchesVersion');
|
||||||
return patchesVersion ?? '0.0.0';
|
return patchesVersion ?? '0.0.0';
|
||||||
|
} else {
|
||||||
|
// fetch from github
|
||||||
|
patchesVersion = await _githubAPI
|
||||||
|
.getLastestReleaseVersion(_managerAPI.getPatchesRepo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Patch> getQueriedPatches(String query) {
|
List<Patch> getQueriedPatches(String query) {
|
||||||
|
Loading…
Reference in New Issue
Block a user