diff --git a/src/globals.rs b/src/globals.rs index 080111ba..c87b6841 100644 --- a/src/globals.rs +++ b/src/globals.rs @@ -59,6 +59,9 @@ pub struct Globals { /// Signer pub signer: RwLock, + + /// Dismissed Events + pub dismissed: RwLock>, } lazy_static! { @@ -84,6 +87,7 @@ lazy_static! { shutting_down: AtomicBool::new(false), settings: RwLock::new(Settings::default()), signer: RwLock::new(Signer::default()), + dismissed: RwLock::new(Vec::new()), } }; } @@ -96,6 +100,7 @@ impl Globals { .iter() .map(|(_, e)| e) .filter(|e| e.kind == EventKind::TextNote) + .filter(|e| !GLOBALS.dismissed.blocking_read().contains(&e.id)) .filter(|e| { if threaded { e.replies_to().is_none() @@ -274,7 +279,7 @@ impl Globals { // FIXME - this allows people to react many times to the same event, and // it counts them all! - pub fn get_reactions_sync(id: Id) -> HashMap { + pub fn get_reactions_sync(id: Id) -> Vec<(char, usize)> { let mut output: HashMap = HashMap::new(); if let Some(relationships) = GLOBALS.relationships.blocking_read().get(&id).cloned() { @@ -295,7 +300,9 @@ impl Globals { } } - output + let mut v: Vec<(char, usize)> = output.iter().map(|(c, u)| (*c, *u)).collect(); + v.sort(); + v } } diff --git a/src/overlord/mod.rs b/src/overlord/mod.rs index cf707028..3fb81948 100644 --- a/src/overlord/mod.rs +++ b/src/overlord/mod.rs @@ -494,7 +494,11 @@ impl Overlord { info!("Seeking {} events", desired_count); - let urls: Vec = desired_events_map.keys().map(|u| u.to_owned()).filter(|u| u.is_valid()).collect(); + let urls: Vec = desired_events_map + .keys() + .map(|u| u.to_owned()) + .filter(|u| u.is_valid()) + .collect(); for url in urls.iter() { // Get all the ones slated for this relay diff --git a/src/ui/feed.rs b/src/ui/feed.rs index 3ca60bdb..91e0c0cc 100644 --- a/src/ui/feed.rs +++ b/src/ui/feed.rs @@ -163,20 +163,20 @@ fn render_post( } ui.with_layout(Layout::right_to_left(Align::TOP), |ui| { + ui.menu_button(RichText::new("≡").size(28.0), |ui| { + if ui.button("Copy ID").clicked() { + ui.output().copied_text = event.id.as_hex_string(); + } + if ui.button("Dismiss").clicked() { + GLOBALS.dismissed.blocking_write().push(event.id); + } + }); + ui.label( RichText::new(crate::date_ago::date_ago(event.created_at)) .italics() .weak(), ); - - ui.add_space(10.0); - - if ui.add(CopyButton {}).clicked() { - ui.output().copied_text = event.id.as_hex_string(); - } - ui.label("[ID]").on_hover_ui(|ui| { - ui.label(&format!("ID: {}", event.id.as_hex_string())); - }); }); });