Clean up unused catalog function and wire source info into catalog view

This commit is contained in:
lashman
2026-02-28 00:25:05 +02:00
parent f12e74ba2b
commit 31da61f3da
2 changed files with 12 additions and 20 deletions

View File

@@ -94,24 +94,6 @@ pub fn sync_catalog(db: &Database, source: &CatalogSource) -> Result<u32, Catalo
Ok(count)
}
/// Search the local catalog database for apps matching a query.
pub fn search_catalog(db: &Database, query: &str) -> Vec<CatalogApp> {
let records = db.search_catalog_apps(query).unwrap_or_default();
records.into_iter().map(|r| CatalogApp {
name: r.name,
description: r.description,
categories: r.categories
.map(|c| c.split(", ").map(String::from).collect())
.unwrap_or_default(),
latest_version: r.latest_version,
download_url: r.download_url,
icon_url: r.icon_url,
homepage: r.homepage,
file_size: r.file_size.map(|s| s as u64),
architecture: r.architecture,
}).collect()
}
/// Download an AppImage from the catalog to a local directory.
pub fn install_from_catalog(app: &CatalogApp, install_dir: &Path) -> Result<PathBuf, CatalogError> {
fs::create_dir_all(install_dir).map_err(|e| CatalogError::Io(e.to_string()))?;
@@ -351,7 +333,7 @@ mod tests {
#[test]
fn test_search_catalog_empty() {
let db = crate::core::database::Database::open_in_memory().unwrap();
let results = search_catalog(&db, "firefox");
let results = db.search_catalog_apps("firefox").unwrap();
assert!(results.is_empty());
}

View File

@@ -95,10 +95,20 @@ pub fn build_catalog_page(db: &Rc<Database>) -> adw::NavigationPage {
stack.add_named(&scrolled, Some("results"));
// Show empty or results based on catalog data
let sources = catalog::get_sources(db);
let enabled_sources: Vec<_> = sources.iter().filter(|s| s.enabled).collect();
let app_count = db.catalog_app_count().unwrap_or(0);
if app_count > 0 {
stack.set_visible_child_name("results");
title.set_subtitle(&format!("{} apps available", app_count));
if let Some(src) = enabled_sources.first() {
let synced = src.last_synced.as_deref().unwrap_or("never");
title.set_subtitle(&format!(
"{} apps from {} ({}), synced: {}",
src.app_count, src.name, src.source_type.as_str(), synced,
));
} else {
title.set_subtitle(&format!("{} apps available", app_count));
}
} else {
stack.set_visible_child_name("empty");
}