diff --git a/src/ui/feed.rs b/src/ui/feed.rs index 511fbe83..a2d09482 100644 --- a/src/ui/feed.rs +++ b/src/ui/feed.rs @@ -4,7 +4,8 @@ use crate::globals::{Globals, GLOBALS}; use crate::ui::widgets::{CopyButton, ReplyButton}; use eframe::egui; use egui::{ - Align, Color32, Context, Frame, Layout, RichText, ScrollArea, TextEdit, TextStyle, Ui, Vec2, + Align, Color32, Context, Frame, Label, Layout, RichText, ScrollArea, Sense, TextEdit, + TextStyle, Ui, Vec2, }; use nostr_types::{EventKind, Id}; @@ -201,6 +202,17 @@ fn render_post( ui.horizontal(|ui| { // Indents first (if threaded) if threaded { + #[allow(clippy::collapsible_else_if)] + if app.hides.contains(&id) { + if ui.add(Label::new("▶").sense(Sense::click())).clicked() { + app.hides.retain(|e| *e != id) + } + } else { + if ui.add(Label::new("▼").sense(Sense::click())).clicked() { + app.hides.push(id); + } + } + let space = 16.0 * (10.0 - (100.0 / (indent as f32 + 10.0))); ui.add_space(space); if indent > 0 { @@ -301,7 +313,7 @@ fn render_post( ui.separator(); - if threaded && !as_reply_to { + if threaded && !as_reply_to && !app.hides.contains(&id) { for reply_id in replies { render_post(app, _ctx, _frame, ui, reply_id, indent + 1, as_reply_to); } diff --git a/src/ui/mod.rs b/src/ui/mod.rs index 96c7eab7..a788da4b 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -75,6 +75,7 @@ struct GossipUi { import_bech32: String, import_hex: String, replying_to: Option, + hides: Vec, } impl Drop for GossipUi { @@ -141,6 +142,7 @@ impl GossipUi { import_bech32: "".to_owned(), import_hex: "".to_owned(), replying_to: None, + hides: Vec::new(), } } }