Skip to content

Commit

Permalink
fix: Get changelogs for alternative sources (#1766)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheAabedKhan authored Sep 19, 2024
1 parent d53f8cf commit c729842
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
19 changes: 14 additions & 5 deletions lib/services/manager_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -119,6 +123,9 @@ class ManagerAPI {
}

String getPatchesRepo() {
if (!isUsingAlternativeSources()) {
return defaultPatchesRepo;
}
return _prefs.getString('patchesRepo') ?? defaultPatchesRepo;
}

Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/views/home/home_viewmodel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

Expand Down

0 comments on commit c729842

Please sign in to comment.