notedeck

One damus client to rule them all
git clone git://jb55.com/notedeck
Log | Files | Refs | README | LICENSE

query_ui.rs (1732B)


      1 /// UI components for displaying query call information.
      2 ///
      3 /// These components render the parameters of a nostr query in a visual format,
      4 /// using pill labels to show search terms, authors, limits, and other filter criteria.
      5 use super::pill::{pill_label, pill_label_ui};
      6 use crate::tools::QueryCall;
      7 use nostrdb::{Ndb, Transaction};
      8 use notedeck::{Images, MediaJobSender};
      9 use notedeck_ui::ProfilePic;
     10 
     11 /// Render query call parameters as pill labels
     12 pub fn query_call_ui(
     13     cache: &mut Images,
     14     ndb: &Ndb,
     15     query: &QueryCall,
     16     jobs: &MediaJobSender,
     17     ui: &mut egui::Ui,
     18 ) {
     19     ui.spacing_mut().item_spacing.x = 8.0;
     20     if let Some(pubkey) = query.author() {
     21         let txn = Transaction::new(ndb).unwrap();
     22         pill_label_ui(
     23             "author",
     24             move |ui| {
     25                 ui.add(
     26                     &mut ProfilePic::from_profile_or_default(
     27                         cache,
     28                         jobs,
     29                         ndb.get_profile_by_pubkey(&txn, pubkey.bytes())
     30                             .ok()
     31                             .as_ref(),
     32                     )
     33                     .size(ProfilePic::small_size() as f32),
     34                 );
     35             },
     36             ui,
     37         );
     38     }
     39 
     40     if let Some(limit) = query.limit {
     41         pill_label("limit", &limit.to_string(), ui);
     42     }
     43 
     44     if let Some(since) = query.since {
     45         pill_label("since", &since.to_string(), ui);
     46     }
     47 
     48     if let Some(kind) = query.kind {
     49         pill_label("kind", &kind.to_string(), ui);
     50     }
     51 
     52     if let Some(until) = query.until {
     53         pill_label("until", &until.to_string(), ui);
     54     }
     55 
     56     if let Some(search) = query.search.as_ref() {
     57         pill_label("search", search, ui);
     58     }
     59 }