Revert "Optimize multi-repo detection: use lightweight database check, avoid network fetches"

This reverts commit e2cd3caa1e.
This commit is contained in:
nahnah
2026-01-28 15:37:04 +00:00
parent 2f5638c43e
commit 2637c7802a
3 changed files with 4 additions and 55 deletions
+4 -6
View File
@@ -220,7 +220,6 @@ class AppProvider extends ChangeNotifier {
/// Enriches a single app with repository information from all enabled repositories
/// This is useful when displaying app details to show which repositories host the app
/// Only checks database - does not trigger network fetches for performance
Future<FDroidApp> enrichAppWithRepositories(
FDroidApp app,
RepositoriesProvider? repositoriesProvider,
@@ -259,7 +258,6 @@ class AppProvider extends ChangeNotifier {
}
// Query all repositories in parallel for better performance
// Use lightweight database-only check - no network fetches
final repoChecks = await Future.wait(
enabledRepos.map((repo) async {
try {
@@ -268,14 +266,14 @@ class AppProvider extends ChangeNotifier {
return null;
}
// Check if app exists in this repository's database (lightweight, no network)
final exists = await _apiService.hasAppInRepository(
app.packageName,
// Try to find the app in this repository via database
final results = await _apiService.searchAppsFromRepositoryUrl(
app.packageName, // Use exact package name for lookup
repo.url,
);
// If found in this repository, return the source
if (exists) {
if (results.any((a) => a.packageName == app.packageName)) {
return RepositorySource(name: repo.name, url: repo.url);
}
} catch (e) {
-38
View File
@@ -568,44 +568,6 @@ class DatabaseService {
return apps;
}
/// Checks if an app exists in a specific repository (database only, no network fetch)
/// Returns true if the app is found in the repository's database
Future<bool> hasAppInRepository(
String packageName,
String repositoryUrl,
) async {
try {
final db = await database;
// Get repository ID by URL
final repoResults = await db.query(
_repositoriesTable,
columns: ['id'],
where: 'url = ?',
whereArgs: [repositoryUrl],
);
if (repoResults.isEmpty) {
return false; // Repository not found in database
}
final repositoryId = repoResults.first['id'] as int;
// Check if app exists in this repository
final appResults = await db.query(
_appsTable,
columns: ['package_name'],
where: 'package_name = ? AND repository_id = ?',
whereArgs: [packageName, repositoryId],
limit: 1,
);
return appResults.isNotEmpty;
} catch (e) {
return false;
}
}
/// Searches apps by repository URL
Future<List<FDroidApp>> searchAppsByRepository(
String query,
-11
View File
@@ -517,17 +517,6 @@ class FDroidApiService {
}
}
/// Checks if an app exists in a specific repository (database only, no network fetch)
Future<bool> hasAppInRepository(
String packageName,
String repositoryUrl,
) async {
return await _databaseService.hasAppInRepository(
packageName,
repositoryUrl,
);
}
/// Fetches all available categories
Future<List<String>> fetchCategories() async {
try {