mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Ability to collapse threads
This commit is contained in:
parent
409860ab29
commit
aeab1e98b1
@ -4,7 +4,8 @@ use crate::globals::{Globals, GLOBALS};
|
|||||||
use crate::ui::widgets::{CopyButton, ReplyButton};
|
use crate::ui::widgets::{CopyButton, ReplyButton};
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use 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};
|
use nostr_types::{EventKind, Id};
|
||||||
|
|
||||||
@ -201,6 +202,17 @@ fn render_post(
|
|||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
// Indents first (if threaded)
|
// Indents first (if threaded)
|
||||||
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)));
|
let space = 16.0 * (10.0 - (100.0 / (indent as f32 + 10.0)));
|
||||||
ui.add_space(space);
|
ui.add_space(space);
|
||||||
if indent > 0 {
|
if indent > 0 {
|
||||||
@ -301,7 +313,7 @@ fn render_post(
|
|||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
|
||||||
if threaded && !as_reply_to {
|
if threaded && !as_reply_to && !app.hides.contains(&id) {
|
||||||
for reply_id in replies {
|
for reply_id in replies {
|
||||||
render_post(app, _ctx, _frame, ui, reply_id, indent + 1, as_reply_to);
|
render_post(app, _ctx, _frame, ui, reply_id, indent + 1, as_reply_to);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ struct GossipUi {
|
|||||||
import_bech32: String,
|
import_bech32: String,
|
||||||
import_hex: String,
|
import_hex: String,
|
||||||
replying_to: Option<Id>,
|
replying_to: Option<Id>,
|
||||||
|
hides: Vec<Id>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for GossipUi {
|
impl Drop for GossipUi {
|
||||||
@ -141,6 +142,7 @@ impl GossipUi {
|
|||||||
import_bech32: "".to_owned(),
|
import_bech32: "".to_owned(),
|
||||||
import_hex: "".to_owned(),
|
import_hex: "".to_owned(),
|
||||||
replying_to: None,
|
replying_to: None,
|
||||||
|
hides: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user