Hamburger menu on each post. Dismiss option.

This commit is contained in:
Mike Dilger 2022-12-29 15:06:43 +13:00
parent 05b6e91a6e
commit 352b674a60
3 changed files with 23 additions and 12 deletions

View File

@ -59,6 +59,9 @@ pub struct Globals {
/// Signer
pub signer: RwLock<Signer>,
/// Dismissed Events
pub dismissed: RwLock<Vec<Id>>,
}
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<char, usize> {
pub fn get_reactions_sync(id: Id) -> Vec<(char, usize)> {
let mut output: HashMap<char, usize> = 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
}
}

View File

@ -494,7 +494,11 @@ impl Overlord {
info!("Seeking {} events", desired_count);
let urls: Vec<Url> = desired_events_map.keys().map(|u| u.to_owned()).filter(|u| u.is_valid()).collect();
let urls: Vec<Url> = 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

View File

@ -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()));
});
});
});