fix: Get changelogs for alternative sources (#1766)

This commit is contained in:
aAbed 2024-09-20 04:42:07 +05:45 committed by GitHub
parent d53f8cf130
commit c7298424e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 6 deletions

View file

@ -69,7 +69,8 @@ class ManagerAPI {
}
// Migrate to new API URL if not done yet as the old one is sunset.
final bool hasMigratedToNewApi = _prefs.getBool('migratedToNewApiUrl') ?? false;
final bool hasMigratedToNewApi =
_prefs.getBool('migratedToNewApiUrl') ?? false;
if (!hasMigratedToNewApi) {
final String apiUrl = getApiUrl().toLowerCase();
if (apiUrl.contains('releases.revanced.app')) {
@ -78,11 +79,14 @@ class ManagerAPI {
}
}
final bool hasMigratedToAlternativeSource = _prefs.getBool('migratedToAlternativeSource') ?? false;
final bool hasMigratedToAlternativeSource =
_prefs.getBool('migratedToAlternativeSource') ?? false;
if (!hasMigratedToAlternativeSource) {
final String patchesRepo = getPatchesRepo();
final String integrationsRepo = getIntegrationsRepo();
final bool usingAlternativeSources = patchesRepo.toLowerCase() != defaultPatchesRepo || integrationsRepo.toLowerCase() != defaultIntegrationsRepo;
final bool usingAlternativeSources =
patchesRepo.toLowerCase() != defaultPatchesRepo ||
integrationsRepo.toLowerCase() != defaultIntegrationsRepo;
_prefs.setBool('useAlternativeSources', usingAlternativeSources);
_prefs.setBool('migratedToAlternativeSource', true);
}
@ -119,6 +123,9 @@ class ManagerAPI {
}
String getPatchesRepo() {
if (!isUsingAlternativeSources()) {
return defaultPatchesRepo;
}
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
}
@ -452,7 +459,7 @@ class ManagerAPI {
Future<File?> downloadPatches() async {
try {
final String repoName = !isUsingAlternativeSources() ? defaultPatchesRepo : getPatchesRepo();
final String repoName = getPatchesRepo();
final String currentVersion = await getCurrentPatchesVersion();
final String url = getPatchesDownloadURL();
return await _githubAPI.getReleaseFile(
@ -471,7 +478,9 @@ class ManagerAPI {
Future<File?> downloadIntegrations() async {
try {
final String repoName = !isUsingAlternativeSources() ? defaultIntegrationsRepo : getIntegrationsRepo();
final String repoName = !isUsingAlternativeSources()
? defaultIntegrationsRepo
: getIntegrationsRepo();
final String currentVersion = await getCurrentIntegrationsVersion();
final String url = getIntegrationsDownloadURL();
return await _githubAPI.getReleaseFile(

View file

@ -484,7 +484,7 @@ class HomeViewModel extends BaseViewModel {
Future<String?> getLatestPatchesChangelog() async {
final release =
await _githubAPI.getLatestRelease(_managerAPI.defaultPatchesRepo);
await _githubAPI.getLatestRelease(_managerAPI.getPatchesRepo());
return release?['body'];
}