mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: pair integrations and patches updates (#1102)
This commit is contained in:
parent
1714c3fa86
commit
722a5859a5
2 changed files with 46 additions and 10 deletions
|
@ -36,10 +36,15 @@ class ManagerAPI {
|
||||||
String defaultCliRepo = 'revanced/revanced-cli';
|
String defaultCliRepo = 'revanced/revanced-cli';
|
||||||
String defaultManagerRepo = 'revanced/revanced-manager';
|
String defaultManagerRepo = 'revanced/revanced-manager';
|
||||||
String? patchesVersion = '';
|
String? patchesVersion = '';
|
||||||
|
String? integrationsVersion = '';
|
||||||
bool isDefaultPatchesRepo() {
|
bool isDefaultPatchesRepo() {
|
||||||
return getPatchesRepo() == 'revanced/revanced-patches';
|
return getPatchesRepo() == 'revanced/revanced-patches';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isDefaultIntegrationsRepo() {
|
||||||
|
return getIntegrationsRepo() == 'revanced/revanced-integrations';
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
_prefs = await SharedPreferences.getInstance();
|
_prefs = await SharedPreferences.getInstance();
|
||||||
isRooted = await _rootAPI.isRooted();
|
isRooted = await _rootAPI.isRooted();
|
||||||
|
@ -267,14 +272,12 @@ class ManagerAPI {
|
||||||
Future<File?> downloadIntegrations() async {
|
Future<File?> downloadIntegrations() async {
|
||||||
try {
|
try {
|
||||||
final String repoName = getIntegrationsRepo();
|
final String repoName = getIntegrationsRepo();
|
||||||
if (repoName == defaultIntegrationsRepo) {
|
final String currentVersion = await getCurrentIntegrationsVersion();
|
||||||
return await _revancedAPI.getLatestReleaseFile(
|
return await _githubAPI.getPatchesReleaseFile(
|
||||||
'.apk',
|
'.apk',
|
||||||
defaultIntegrationsRepo,
|
repoName,
|
||||||
);
|
currentVersion,
|
||||||
} else {
|
);
|
||||||
return await _githubAPI.getLatestReleaseFile('.apk', repoName);
|
|
||||||
}
|
|
||||||
} on Exception catch (e) {
|
} on Exception catch (e) {
|
||||||
if (kDebugMode) {
|
if (kDebugMode) {
|
||||||
print(e);
|
print(e);
|
||||||
|
@ -323,6 +326,22 @@ class ManagerAPI {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String?> getLatestIntegrationsVersion() async {
|
||||||
|
if (isDefaultIntegrationsRepo()) {
|
||||||
|
return await _revancedAPI.getLatestReleaseVersion(
|
||||||
|
'.apk',
|
||||||
|
defaultIntegrationsRepo,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final release = await _githubAPI.getLatestRelease(getIntegrationsRepo());
|
||||||
|
if (release != null) {
|
||||||
|
return release['tag_name'];
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<String?> getLatestPatchesVersion() async {
|
Future<String?> getLatestPatchesVersion() async {
|
||||||
if (isDefaultPatchesRepo()) {
|
if (isDefaultPatchesRepo()) {
|
||||||
return await _revancedAPI.getLatestReleaseVersion(
|
return await _revancedAPI.getLatestReleaseVersion(
|
||||||
|
@ -330,7 +349,8 @@ class ManagerAPI {
|
||||||
defaultPatchesRepo,
|
defaultPatchesRepo,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
final release = await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
|
final release =
|
||||||
|
await _githubAPI.getLatestPatchesRelease(getPatchesRepo());
|
||||||
if (release != null) {
|
if (release != null) {
|
||||||
return release['tag_name'];
|
return release['tag_name'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -357,6 +377,19 @@ class ManagerAPI {
|
||||||
await _prefs.setString('patchesVersion', version);
|
await _prefs.setString('patchesVersion', version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<String> getCurrentIntegrationsVersion() async {
|
||||||
|
integrationsVersion = _prefs.getString('integrationsVersion') ?? '0.0.0';
|
||||||
|
if (integrationsVersion == '0.0.0' || isPatchesAutoUpdate()) {
|
||||||
|
integrationsVersion = await getLatestIntegrationsVersion() ?? '0.0.0';
|
||||||
|
await setCurrentIntegrationsVersion(integrationsVersion!);
|
||||||
|
}
|
||||||
|
return integrationsVersion!;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setCurrentIntegrationsVersion(String version) async {
|
||||||
|
await _prefs.setString('integrationsVersion', version);
|
||||||
|
}
|
||||||
|
|
||||||
Future<List<PatchedApplication>> getAppsToRemove(
|
Future<List<PatchedApplication>> getAppsToRemove(
|
||||||
List<PatchedApplication> patchedApps,
|
List<PatchedApplication> patchedApps,
|
||||||
) async {
|
) async {
|
||||||
|
|
|
@ -253,9 +253,12 @@ class HomeViewModel extends BaseViewModel {
|
||||||
_toast.showBottom('homeView.downloadingMessage');
|
_toast.showBottom('homeView.downloadingMessage');
|
||||||
final String patchesVersion =
|
final String patchesVersion =
|
||||||
await _managerAPI.getLatestPatchesVersion() ?? '0.0.0';
|
await _managerAPI.getLatestPatchesVersion() ?? '0.0.0';
|
||||||
if (patchesVersion != '0.0.0') {
|
final String integrationsVersion =
|
||||||
|
await _managerAPI.getLatestIntegrationsVersion() ?? '0.0.0';
|
||||||
|
if (patchesVersion != '0.0.0' && integrationsVersion != '0.0.0') {
|
||||||
_toast.showBottom('homeView.downloadedMessage');
|
_toast.showBottom('homeView.downloadedMessage');
|
||||||
await _managerAPI.setCurrentPatchesVersion(patchesVersion);
|
await _managerAPI.setCurrentPatchesVersion(patchesVersion);
|
||||||
|
await _managerAPI.setCurrentIntegrationsVersion(integrationsVersion);
|
||||||
forceRefresh(context);
|
forceRefresh(context);
|
||||||
} else {
|
} else {
|
||||||
_toast.showBottom('homeView.errorDownloadMessage');
|
_toast.showBottom('homeView.errorDownloadMessage');
|
||||||
|
|
Loading…
Reference in a new issue