Fix broken thrid-party f-droid search (#1094)

This commit is contained in:
Imran Remtulla
2023-11-18 14:53:43 -05:00
parent 6102ab4be8
commit 4c53b58fd8
3 changed files with 9 additions and 5 deletions

View File

@@ -214,7 +214,8 @@ class _ImportExportPageState extends State<ImportExportPage> {
); );
}); });
if (selectedUrls != null && selectedUrls.isNotEmpty) { if (selectedUrls != null && selectedUrls.isNotEmpty) {
var errors = await appsProvider.addAppsByURL(selectedUrls); var errors = await appsProvider.addAppsByURL(selectedUrls,
sourceOverride: source);
if (errors.isEmpty) { if (errors.isEmpty) {
// ignore: use_build_context_synchronously // ignore: use_build_context_synchronously
showMessage( showMessage(

View File

@@ -1217,9 +1217,11 @@ class AppsProvider with ChangeNotifier {
super.dispose(); super.dispose();
} }
Future<List<List<String>>> addAppsByURL(List<String> urls) async { Future<List<List<String>>> addAppsByURL(List<String> urls,
{AppSource? sourceOverride}) async {
List<dynamic> results = await SourceProvider().getAppsByURLNaive(urls, List<dynamic> results = await SourceProvider().getAppsByURLNaive(urls,
alreadyAddedUrls: apps.values.map((e) => e.app.url).toList()); alreadyAddedUrls: apps.values.map((e) => e.app.url).toList(),
sourceOverride: sourceOverride);
List<App> pps = results[0]; List<App> pps = results[0];
Map<String, dynamic> errorsMap = results[1]; Map<String, dynamic> errorsMap = results[1];
for (var app in pps) { for (var app in pps) {

View File

@@ -706,7 +706,8 @@ class SourceProvider {
// Returns errors in [results, errors] instead of throwing them // Returns errors in [results, errors] instead of throwing them
Future<List<dynamic>> getAppsByURLNaive(List<String> urls, Future<List<dynamic>> getAppsByURLNaive(List<String> urls,
{List<String> alreadyAddedUrls = const []}) async { {List<String> alreadyAddedUrls = const [],
AppSource? sourceOverride}) async {
List<App> apps = []; List<App> apps = [];
Map<String, dynamic> errors = {}; Map<String, dynamic> errors = {};
for (var url in urls) { for (var url in urls) {
@@ -714,7 +715,7 @@ class SourceProvider {
if (alreadyAddedUrls.contains(url)) { if (alreadyAddedUrls.contains(url)) {
throw ObtainiumError(tr('appAlreadyAdded')); throw ObtainiumError(tr('appAlreadyAdded'));
} }
var source = getSource(url); var source = sourceOverride ?? getSource(url);
apps.add(await getApp( apps.add(await getApp(
source, source,
url, url,