Merge tombstone muted notes #606

Changelog-Changed: Tombstone muted notes
This commit is contained in:
William Casarin
2025-01-04 14:08:33 -08:00
18 changed files with 134 additions and 125 deletions

View File

@@ -503,7 +503,6 @@ pub fn render_add_column_routes(
ctx.pool,
ctx.note_cache,
app.since_optimize,
&ctx.accounts.mutefun(),
ctx.accounts
.get_selected_account()
.as_ref()

View File

@@ -29,6 +29,7 @@ pub struct ProfileView<'a> {
ndb: &'a Ndb,
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
is_muted: &'a MuteFun,
}
pub enum ProfileViewAction {
@@ -46,6 +47,7 @@ impl<'a> ProfileView<'a> {
ndb: &'a Ndb,
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
is_muted: &'a MuteFun,
note_options: NoteOptions,
) -> Self {
ProfileView {
@@ -57,10 +59,11 @@ impl<'a> ProfileView<'a> {
note_cache,
img_cache,
note_options,
is_muted,
}
}
pub fn ui(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<ProfileViewAction> {
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<ProfileViewAction> {
let scroll_id = egui::Id::new(("profile_scroll", self.col_id, self.pubkey));
ScrollArea::vertical()
@@ -75,20 +78,14 @@ impl<'a> ProfileView<'a> {
}
let profile = self
.profiles
.notes_holder_mutated(
self.ndb,
self.note_cache,
&txn,
self.pubkey.bytes(),
is_muted,
)
.notes_holder_mutated(self.ndb, self.note_cache, &txn, self.pubkey.bytes())
.get_ptr();
profile.timeline.selected_view =
tabs_ui(ui, profile.timeline.selected_view, &profile.timeline.views);
// poll for new notes and insert them into our existing notes
if let Err(e) = profile.poll_notes_into_view(&txn, self.ndb, is_muted) {
if let Err(e) = profile.poll_notes_into_view(&txn, self.ndb) {
error!("Profile::poll_notes_into_view: {e}");
}
@@ -102,11 +99,13 @@ impl<'a> ProfileView<'a> {
self.ndb,
self.note_cache,
self.img_cache,
self.is_muted,
)
.show(ui)
{
action = Some(ProfileViewAction::Note(note_action));
}
action
})
.inner

View File

@@ -20,6 +20,7 @@ pub struct ThreadView<'a> {
selected_note_id: &'a [u8; 32],
textmode: bool,
id_source: egui::Id,
is_muted: &'a MuteFun,
}
impl<'a> ThreadView<'a> {
@@ -32,6 +33,7 @@ impl<'a> ThreadView<'a> {
img_cache: &'a mut ImageCache,
selected_note_id: &'a [u8; 32],
textmode: bool,
is_muted: &'a MuteFun,
) -> Self {
let id_source = egui::Id::new("threadscroll_threadview");
ThreadView {
@@ -43,6 +45,7 @@ impl<'a> ThreadView<'a> {
selected_note_id,
textmode,
id_source,
is_muted,
}
}
@@ -51,7 +54,7 @@ impl<'a> ThreadView<'a> {
self
}
pub fn ui(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<NoteAction> {
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
let txn = Transaction::new(self.ndb).expect("txn");
let selected_note_key =
@@ -93,13 +96,13 @@ impl<'a> ThreadView<'a> {
let thread = self
.threads
.notes_holder_mutated(self.ndb, self.note_cache, &txn, root_id, is_muted)
.notes_holder_mutated(self.ndb, self.note_cache, &txn, root_id)
.get_ptr();
// TODO(jb55): skip poll if ThreadResult is fresh?
// poll for new notes and insert them into our existing notes
match thread.poll_notes_into_view(&txn, self.ndb, is_muted) {
match thread.poll_notes_into_view(&txn, self.ndb) {
Ok(action) => {
action.process_action(&txn, self.ndb, self.unknown_ids, self.note_cache)
}
@@ -119,6 +122,7 @@ impl<'a> ThreadView<'a> {
self.ndb,
self.note_cache,
self.img_cache,
self.is_muted,
)
.show(ui)
})

View File

@@ -7,10 +7,11 @@ use crate::{
ui::note::NoteOptions,
};
use egui::containers::scroll_area::ScrollBarVisibility;
use egui::{Direction, Layout};
use egui::{Color32, Direction, Layout};
use egui_tabs::TabColor;
use nostrdb::{Ndb, Transaction};
use notedeck::{ImageCache, NoteCache};
use notedeck::note::root_note_id_from_selected_id;
use notedeck::{ImageCache, MuteFun, NoteCache};
use tracing::{error, warn};
pub struct TimelineView<'a> {
@@ -21,6 +22,7 @@ pub struct TimelineView<'a> {
img_cache: &'a mut ImageCache,
note_options: NoteOptions,
reverse: bool,
is_muted: &'a MuteFun,
}
impl<'a> TimelineView<'a> {
@@ -31,6 +33,7 @@ impl<'a> TimelineView<'a> {
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
note_options: NoteOptions,
is_muted: &'a MuteFun,
) -> TimelineView<'a> {
let reverse = false;
TimelineView {
@@ -41,6 +44,7 @@ impl<'a> TimelineView<'a> {
img_cache,
reverse,
note_options,
is_muted,
}
}
@@ -54,6 +58,7 @@ impl<'a> TimelineView<'a> {
self.img_cache,
self.reverse,
self.note_options,
self.is_muted,
)
}
@@ -73,6 +78,7 @@ fn timeline_ui(
img_cache: &mut ImageCache,
reversed: bool,
note_options: NoteOptions,
is_muted: &MuteFun,
) -> Option<NoteAction> {
//padding(4.0, ui, |ui| ui.heading("Notifications"));
/*
@@ -123,6 +129,7 @@ fn timeline_ui(
ndb,
note_cache,
img_cache,
is_muted,
)
.show(ui)
})
@@ -224,9 +231,11 @@ pub struct TimelineTabView<'a> {
ndb: &'a Ndb,
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
is_muted: &'a MuteFun,
}
impl<'a> TimelineTabView<'a> {
#[allow(clippy::too_many_arguments)]
pub fn new(
tab: &'a TimelineTab,
reversed: bool,
@@ -235,6 +244,7 @@ impl<'a> TimelineTabView<'a> {
ndb: &'a Ndb,
note_cache: &'a mut NoteCache,
img_cache: &'a mut ImageCache,
is_muted: &'a MuteFun,
) -> Self {
Self {
tab,
@@ -244,6 +254,7 @@ impl<'a> TimelineTabView<'a> {
ndb,
note_cache,
img_cache,
is_muted,
}
}
@@ -251,6 +262,7 @@ impl<'a> TimelineTabView<'a> {
let mut action: Option<NoteAction> = None;
let len = self.tab.notes.len();
let is_muted = self.is_muted;
self.tab
.list
.clone()
@@ -275,17 +287,30 @@ impl<'a> TimelineTabView<'a> {
};
ui::padding(8.0, ui, |ui| {
let resp = ui::NoteView::new(self.ndb, self.note_cache, self.img_cache, &note)
.note_options(self.note_options)
.show(ui);
if let Some(muted_reason) = is_muted(
&note,
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 resp =
ui::NoteView::new(self.ndb, self.note_cache, self.img_cache, &note)
.note_options(self.note_options)
.show(ui);
if let Some(note_action) = resp.action {
action = Some(note_action)
}
if let Some(note_action) = resp.action {
action = Some(note_action)
}
if let Some(context) = resp.context_selection {
context.process(ui, &note);
}
if let Some(context) = resp.context_selection {
context.process(ui, &note);
}
};
});
ui::hline(ui);