mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-19 13:09:30 +02:00
Fix occasional RangeError after importing apps (#2438)
This commit is contained in:
@@ -14,7 +14,6 @@ import 'package:obtainium/pages/import_export.dart';
|
||||
import 'package:obtainium/pages/settings.dart';
|
||||
import 'package:obtainium/providers/apps_provider.dart';
|
||||
import 'package:obtainium/providers/settings_provider.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
||||
@@ -201,14 +200,6 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
context,
|
||||
);
|
||||
await appsProvider
|
||||
.checkUpdates(specificIds: result.key.map((e) => e.id).toList())
|
||||
.catchError((e) {
|
||||
if (e is Map && e['errors'] is MultiAppMultiError) {
|
||||
showError(e['errors'].toString(), context);
|
||||
}
|
||||
return <App>[];
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw ObtainiumError(tr('unknown'));
|
||||
|
@@ -1025,13 +1025,19 @@ class AppsProvider with ChangeNotifier {
|
||||
);
|
||||
}
|
||||
getHost(String url) {
|
||||
if (url == 'placeholder') {
|
||||
return null;
|
||||
}
|
||||
var temp = Uri.parse(url).host.split('.');
|
||||
return temp.sublist(temp.length - 2).join('.');
|
||||
}
|
||||
|
||||
// If the picked APK comes from an origin different from the source, get user confirmation (if context provided)
|
||||
if (appFileUrl != null &&
|
||||
getHost(appFileUrl.value) != getHost(app.url) &&
|
||||
![
|
||||
getHost(app.url),
|
||||
'placeholder',
|
||||
].contains(getHost(appFileUrl.value)) &&
|
||||
context != null) {
|
||||
if (!(settingsProvider.hideAPKOriginWarning) &&
|
||||
await showDialog(
|
||||
@@ -1077,7 +1083,8 @@ class AppsProvider with ChangeNotifier {
|
||||
MapEntry<String, String>? apkUrl;
|
||||
var trackOnly = apps[id]!.app.additionalSettings['trackOnly'] == true;
|
||||
var refreshBeforeDownload =
|
||||
apps[id]!.app.additionalSettings['refreshBeforeDownload'] == true;
|
||||
apps[id]!.app.additionalSettings['refreshBeforeDownload'] == true ||
|
||||
apps[id]!.app.apkUrls.first.value == 'placeholder';
|
||||
if (refreshBeforeDownload) {
|
||||
await checkUpdate(apps[id]!.app.id);
|
||||
}
|
||||
@@ -1301,7 +1308,8 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
MapEntry<String, String>? fileUrl;
|
||||
var refreshBeforeDownload =
|
||||
apps[id]!.app.additionalSettings['refreshBeforeDownload'] == true;
|
||||
apps[id]!.app.additionalSettings['refreshBeforeDownload'] == true ||
|
||||
apps[id]!.app.apkUrls.first.value == 'placeholder';
|
||||
if (refreshBeforeDownload) {
|
||||
await checkUpdate(apps[id]!.app.id);
|
||||
}
|
||||
|
Reference in New Issue
Block a user