commit e08e30f9125b9cf7391e97a2683ba0034bff1644
parent c7d3aae856f31f3f4dcf9a79ef50e19754b563e8
Author: William Casarin <jb55@jb55.com>
Date: Sat, 4 Jan 2025 16:19:41 -0800
mutes: simplify mutefun and don't render tombstone yet
Diffstat:
3 files changed, 17 insertions(+), 24 deletions(-)
diff --git a/crates/notedeck/src/accounts.rs b/crates/notedeck/src/accounts.rs
@@ -421,7 +421,7 @@ impl Accounts {
}
}
}
- Box::new(|_: &Note, _: &[u8; 32]| None)
+ Box::new(|_: &Note, _: &[u8; 32]| false)
}
pub fn send_initial_filters(&mut self, pool: &mut RelayPool, relay_url: &str) {
diff --git a/crates/notedeck/src/muted.rs b/crates/notedeck/src/muted.rs
@@ -4,7 +4,7 @@ use std::collections::BTreeSet;
use tracing::{debug, trace};
// If the note is muted return a reason string, otherwise None
-pub type MuteFun = dyn Fn(&Note, &[u8; 32]) -> Option<String>;
+pub type MuteFun = dyn Fn(&Note, &[u8; 32]) -> bool;
#[derive(Default)]
pub struct Muted {
@@ -34,7 +34,7 @@ impl std::fmt::Debug for Muted {
impl Muted {
// If the note is muted return a reason string, otherwise None
- pub fn is_muted(&self, note: &Note, thread: &[u8; 32]) -> Option<String> {
+ pub fn is_muted(&self, note: &Note, thread: &[u8; 32]) -> bool {
trace!(
"{}: thread: {}",
hex::encode(note.id()),
@@ -47,7 +47,7 @@ impl Muted {
hex::encode(note.id()),
hex::encode(note.pubkey())
);
- return Some(format!("pubkey {}", hex::encode(note.pubkey())));
+ return true;
}
// FIXME - Implement hashtag muting here
@@ -69,10 +69,9 @@ impl Muted {
hex::encode(note.id()),
hex::encode(thread)
);
- return Some(format!("thread {}", hex::encode(thread)));
+ return true;
}
- // if we get here it's not muted
- None
+ false
}
}
diff --git a/crates/notedeck_columns/src/ui/timeline.rs b/crates/notedeck_columns/src/ui/timeline.rs
@@ -7,7 +7,7 @@ use crate::{
ui::note::NoteOptions,
};
use egui::containers::scroll_area::ScrollBarVisibility;
-use egui::{Color32, Direction, Layout};
+use egui::{Direction, Layout};
use egui_tabs::TabColor;
use nostrdb::{Ndb, Transaction};
use notedeck::note::root_note_id_from_selected_id;
@@ -286,18 +286,13 @@ impl<'a> TimelineTabView<'a> {
return 0;
};
- ui::padding(8.0, ui, |ui| {
- if let Some(muted_reason) = is_muted(
- ¬e,
- root_note_id_from_selected_id(
- self.ndb,
- self.note_cache,
- self.txn,
- note.id(),
- ),
- ) {
- ui.colored_label(Color32::RED, format!("MUTED {}", muted_reason));
- } else {
+ let muted = is_muted(
+ ¬e,
+ root_note_id_from_selected_id(self.ndb, self.note_cache, self.txn, note.id()),
+ );
+
+ if !muted {
+ ui::padding(8.0, ui, |ui| {
let resp =
ui::NoteView::new(self.ndb, self.note_cache, self.img_cache, ¬e)
.note_options(self.note_options)
@@ -310,11 +305,10 @@ impl<'a> TimelineTabView<'a> {
if let Some(context) = resp.context_selection {
context.process(ui, ¬e);
}
- };
- });
+ });
- ui::hline(ui);
- //ui.add(egui::Separator::default().spacing(0.0));
+ ui::hline(ui);
+ }
1
});