fix: Improve API URL handling and force init after setting a new config

This commit is contained in:
Alberto Ponces 2022-09-19 00:28:26 +01:00
parent c333fa3c33
commit 6c2ceed91f
4 changed files with 26 additions and 56 deletions

View file

@ -9,8 +9,7 @@ import 'package:revanced_manager/models/patch.dart';
@lazySingleton
class GithubAPI {
final String apiUrl = 'https://api.github.com';
final Dio _dio = Dio();
final Dio _dio = Dio(BaseOptions(baseUrl: 'https://api.github.com'));
final DioCacheManager _dioCacheManager = DioCacheManager(CacheConfig());
final Options _cacheOptions = buildCacheOptions(
const Duration(days: 1),
@ -37,7 +36,7 @@ class GithubAPI {
Future<Map<String, dynamic>?> _getLatestRelease(String repoName) async {
try {
var response = await _dio.get(
'$apiUrl/repos/$repoName/releases/latest',
'/repos/$repoName/releases/latest',
options: _cacheOptions,
);
return response.data;
@ -55,7 +54,7 @@ class GithubAPI {
'src/main/kotlin/app/revanced/patches/${repoAppPath[packageName]}';
try {
var response = await _dio.get(
'$apiUrl/repos/$repoName/commits',
'/repos/$repoName/commits',
queryParameters: {
'path': path,
'per_page': 3,