From 2637c7802a0e785090d9c8fb79da377839b5b78d Mon Sep 17 00:00:00 2001 From: nahnah Date: Wed, 28 Jan 2026 15:37:04 +0000 Subject: [PATCH] Revert "Optimize multi-repo detection: use lightweight database check, avoid network fetches" This reverts commit e2cd3caa1e215586177d60e4d12d93291a49fe4a. --- lib/providers/app_provider.dart | 10 +++----- lib/services/database_service.dart | 38 ---------------------------- lib/services/fdroid_api_service.dart | 11 -------- 3 files changed, 4 insertions(+), 55 deletions(-) diff --git a/lib/providers/app_provider.dart b/lib/providers/app_provider.dart index 19c02d1..eabcc69 100644 --- a/lib/providers/app_provider.dart +++ b/lib/providers/app_provider.dart @@ -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 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) { diff --git a/lib/services/database_service.dart b/lib/services/database_service.dart index 8cb2048..5589c88 100644 --- a/lib/services/database_service.dart +++ b/lib/services/database_service.dart @@ -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 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> searchAppsByRepository( String query, diff --git a/lib/services/fdroid_api_service.dart b/lib/services/fdroid_api_service.dart index 669e048..1f991fd 100644 --- a/lib/services/fdroid_api_service.dart +++ b/lib/services/fdroid_api_service.dart @@ -517,17 +517,6 @@ class FDroidApiService { } } - /// Checks if an app exists in a specific repository (database only, no network fetch) - Future hasAppInRepository( - String packageName, - String repositoryUrl, - ) async { - return await _databaseService.hasAppInRepository( - packageName, - repositoryUrl, - ); - } - /// Fetches all available categories Future> fetchCategories() async { try {