Mute rendering instead of ingress
Previous approach was to keep muted content from getting inserted. Instead, this version alters it's display. This makes toggling mutes on and off externally much more stable (the display changes but we don't have to rebuild content trees) For now muted content is collapsed to a red "Muted" tombstone w/ a reason.
This commit is contained in:
@@ -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> {
|
||||
@@ -44,7 +45,7 @@ impl<'a> TimelineView<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
||||
pub fn ui(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<NoteAction> {
|
||||
timeline_ui(
|
||||
ui,
|
||||
self.ndb,
|
||||
@@ -54,6 +55,7 @@ impl<'a> TimelineView<'a> {
|
||||
self.img_cache,
|
||||
self.reverse,
|
||||
self.note_options,
|
||||
is_muted,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -73,6 +75,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"));
|
||||
/*
|
||||
@@ -124,7 +127,7 @@ fn timeline_ui(
|
||||
note_cache,
|
||||
img_cache,
|
||||
)
|
||||
.show(ui)
|
||||
.show(ui, is_muted)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
@@ -247,7 +250,7 @@ impl<'a> TimelineTabView<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn show(&mut self, ui: &mut egui::Ui) -> Option<NoteAction> {
|
||||
pub fn show(&mut self, ui: &mut egui::Ui, is_muted: &MuteFun) -> Option<NoteAction> {
|
||||
let mut action: Option<NoteAction> = None;
|
||||
let len = self.tab.notes.len();
|
||||
|
||||
@@ -275,17 +278,30 @@ impl<'a> TimelineTabView<'a> {
|
||||
};
|
||||
|
||||
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)
|
||||
.show(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 resp =
|
||||
ui::NoteView::new(self.ndb, self.note_cache, self.img_cache, ¬e)
|
||||
.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, ¬e);
|
||||
}
|
||||
if let Some(context) = resp.context_selection {
|
||||
context.process(ui, ¬e);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
ui::hline(ui);
|
||||
|
||||
Reference in New Issue
Block a user