Fix performance, add screenshots, make banner scrollable

This commit is contained in:
2026-02-27 18:44:50 +02:00
parent e69c5f7a7c
commit 0ef4c239f8
8 changed files with 231 additions and 34 deletions

View File

@@ -26,6 +26,7 @@ pub struct AppStreamMetadata {
pub content_rating_summary: Option<String>,
pub releases: Vec<ReleaseInfo>,
pub mime_types: Vec<String>,
pub screenshot_urls: Vec<String>,
}
#[derive(Debug, Clone)]
@@ -64,6 +65,8 @@ pub fn parse_appstream_xml(xml: &str) -> Option<AppStreamMetadata> {
let mut in_content_rating = false;
let mut current_content_attr_id = String::new();
let mut in_developer = false;
let mut in_screenshots = false;
let mut in_screenshot_image = false;
let mut depth = 0u32;
let mut description_depth = 0u32;
let mut release_desc_depth = 0u32;
@@ -161,6 +164,14 @@ pub fn parse_appstream_xml(xml: &str) -> Option<AppStreamMetadata> {
"category" if in_categories => {
current_tag = "category".to_string();
}
"screenshots" if in_component => {
in_screenshots = true;
}
"image" if in_screenshots => {
// Prefer "source" type, but accept any <image>
in_screenshot_image = true;
current_tag = "screenshot_image".to_string();
}
"developer" if in_component => {
in_developer = true;
}
@@ -252,6 +263,12 @@ pub fn parse_appstream_xml(xml: &str) -> Option<AppStreamMetadata> {
"categories" => {
in_categories = false;
}
"screenshots" => {
in_screenshots = false;
}
"image" if in_screenshot_image => {
in_screenshot_image = false;
}
"developer" => {
in_developer = false;
}
@@ -301,6 +318,11 @@ pub fn parse_appstream_xml(xml: &str) -> Option<AppStreamMetadata> {
"category" => {
meta.categories.push(text);
}
"screenshot_image" => {
if text.starts_with("http") && meta.screenshot_urls.len() < 10 {
meta.screenshot_urls.push(text);
}
}
"developer_name" => {
if meta.developer.is_none() {
meta.developer = Some(text);