diff --git a/src/parse/packages.rs b/src/parse/packages.rs index 0707a16..0745c74 100644 --- a/src/parse/packages.rs +++ b/src/parse/packages.rs @@ -22,6 +22,7 @@ pub struct Package { #[serde(skip_deserializing)] pub appdata: Option, } + #[derive(Serialize, Deserialize, PartialEq, Debug, Clone)] pub struct Meta { pub broken: Option, @@ -32,7 +33,7 @@ pub struct Meta { #[serde(rename = "longDescription")] pub longdescription: Option, pub homepage: Option, - pub maintainers: Option>, + pub maintainers: Option, pub position: Option, pub license: Option, pub platforms: Option @@ -75,8 +76,8 @@ pub struct License { #[derive(Serialize, Deserialize, PartialEq, Clone, Debug)] pub struct PkgMaintainer { - pub email: IString, - pub github: IString, + pub email: Option, + pub github: Option, pub matrix: Option, pub name: Option } diff --git a/src/ui/pkgpage.rs b/src/ui/pkgpage.rs index 11d443a..25ab628 100644 --- a/src/ui/pkgpage.rs +++ b/src/ui/pkgpage.rs @@ -869,29 +869,30 @@ impl Component for PkgModel { #[watch] set_label: { let mut s = String::new(); - for p in model.maintainers.iter() { - if model.maintainers.iter().len() == 1 { + let maintainerlist = model.maintainers.iter().filter(|m| m.name.is_some() || m.github.is_some()).collect::>(); + for p in &maintainerlist { + if maintainerlist.len() == 1 { if let Some(n) = &p.name { s.push_str(n); - } else { - s.push_str(&p.github); + } else if let Some(g) = &p.github { + s.push_str(g); } - } else if model.maintainers.iter().len() == 2 && model.maintainers.get(0) == Some(p) { + } else if maintainerlist.len() == 2 && model.maintainers.get(0) == Some(p) { if let Some(n) = &p.name { - let _ = write!(s, "{} ", n.to_string()); - } else { - let _ = write!(s, "{} ", p.github.to_string()); + let _ = write!(s, "{} ", n.as_str()); + } else if let Some(g) = &p.github { + s.push_str(g); } - } else if Some(p) == model.maintainers.iter().last() { + } else if Some(p) == maintainerlist.last() { if let Some(n) = &p.name { - let _ = write!(s, "and {}", n.to_string()); - } else { - let _ = write!(s, "and {}", p.github.to_string()); + let _ = write!(s, "and {}", n.as_str()); + } else if let Some(g) = &p.github { + let _ = write!(s, "and {}", g.as_str()); } } else if let Some(n) = &p.name { - let _ = write!(s, "{}, ", n.to_string()); - } else { - let _ = write!(s, "{}, ", p.github.to_string()); + let _ = write!(s, "{}, ", n.as_str()); + } else if let Some(g) = &p.github { + let _ = write!(s, "{}, ", g.as_str()); } } if model.maintainers.is_empty() { diff --git a/src/ui/window.rs b/src/ui/window.rs index f12e8ba..2f4b0a1 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -5,7 +5,7 @@ use adw::prelude::*; use edit_distance; use serde_json::Value; use spdx::Expression; -use crate::{parse::{packages::{Package, LicenseEnum, Platform}, cache::{uptodatelegacy, uptodateflake}, config::{NscConfig, getconfig, editconfig}}, ui::{installedpage::InstalledItem, pkgpage::PkgPageInit, welcome::WelcomeMsg}, APPINFO, config}; +use crate::{parse::{packages::{Package, LicenseEnum, Platform, PkgMaintainer}, cache::{uptodatelegacy, uptodateflake}, config::{NscConfig, getconfig, editconfig}}, ui::{installedpage::InstalledItem, pkgpage::PkgPageInit, welcome::WelcomeMsg}, APPINFO, config}; use log::*; use super::{ @@ -873,8 +873,10 @@ impl Component for AppModel { platforms.insert(0, input.system.to_string()); if let Some(m) = input.meta.maintainers.clone() { - for m in m { - maintainers.push(m); + if let Ok(m) = ijson::from_value::>(&m) { + for m in m { + maintainers.push(m); + } } }