Merge tombstone muted notes #606
Changelog-Changed: Tombstone muted notes
This commit is contained in:
@@ -7,8 +7,7 @@ use crate::{
|
||||
};
|
||||
|
||||
use notedeck::{
|
||||
filter, CachedNote, FilterError, FilterState, FilterStates, MuteFun, NoteCache, NoteRef,
|
||||
UnknownIds,
|
||||
filter, CachedNote, FilterError, FilterState, FilterStates, NoteCache, NoteRef, UnknownIds,
|
||||
};
|
||||
|
||||
use std::fmt;
|
||||
@@ -287,7 +286,6 @@ impl Timeline {
|
||||
txn: &Transaction,
|
||||
unknown_ids: &mut UnknownIds,
|
||||
note_cache: &mut NoteCache,
|
||||
is_muted: &MuteFun,
|
||||
) -> Result<()> {
|
||||
let timeline = timelines
|
||||
.get_mut(timeline_idx)
|
||||
@@ -312,9 +310,6 @@ impl Timeline {
|
||||
error!("hit race condition in poll_notes_into_view: https://github.com/damus-io/nostrdb/issues/35 note {:?} was not added to timeline", key);
|
||||
continue;
|
||||
};
|
||||
if is_muted(¬e) {
|
||||
continue;
|
||||
}
|
||||
|
||||
UnknownIds::update_from_note(txn, ndb, unknown_ids, note_cache, ¬e);
|
||||
|
||||
@@ -412,12 +407,11 @@ pub fn setup_new_timeline(
|
||||
pool: &mut RelayPool,
|
||||
note_cache: &mut NoteCache,
|
||||
since_optimize: bool,
|
||||
is_muted: &MuteFun,
|
||||
our_pk: Option<&Pubkey>,
|
||||
) {
|
||||
// if we're ready, setup local subs
|
||||
if is_timeline_ready(ndb, pool, note_cache, timeline, is_muted, our_pk) {
|
||||
if let Err(err) = setup_timeline_nostrdb_sub(ndb, note_cache, timeline, is_muted) {
|
||||
if is_timeline_ready(ndb, pool, note_cache, timeline, our_pk) {
|
||||
if let Err(err) = setup_timeline_nostrdb_sub(ndb, note_cache, timeline) {
|
||||
error!("setup_new_timeline: {err}");
|
||||
}
|
||||
}
|
||||
@@ -547,7 +541,6 @@ fn setup_initial_timeline(
|
||||
timeline: &mut Timeline,
|
||||
note_cache: &mut NoteCache,
|
||||
filters: &[Filter],
|
||||
is_muted: &MuteFun,
|
||||
) -> Result<()> {
|
||||
timeline.subscription = Some(ndb.subscribe(filters)?);
|
||||
let txn = Transaction::new(ndb)?;
|
||||
@@ -562,7 +555,7 @@ fn setup_initial_timeline(
|
||||
.map(NoteRef::from_query_result)
|
||||
.collect();
|
||||
|
||||
copy_notes_into_timeline(timeline, &txn, ndb, note_cache, notes, is_muted);
|
||||
copy_notes_into_timeline(timeline, &txn, ndb, note_cache, notes);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -573,7 +566,6 @@ pub fn copy_notes_into_timeline(
|
||||
ndb: &Ndb,
|
||||
note_cache: &mut NoteCache,
|
||||
notes: Vec<NoteRef>,
|
||||
is_muted: &MuteFun,
|
||||
) {
|
||||
let filters = {
|
||||
let views = &timeline.views;
|
||||
@@ -585,9 +577,6 @@ pub fn copy_notes_into_timeline(
|
||||
for note_ref in notes {
|
||||
for (view, filter) in filters.iter().enumerate() {
|
||||
if let Ok(note) = ndb.get_note_by_key(txn, note_ref.key) {
|
||||
if is_muted(¬e) {
|
||||
continue;
|
||||
}
|
||||
if filter(
|
||||
note_cache.cached_note_or_insert_mut(note_ref.key, ¬e),
|
||||
¬e,
|
||||
@@ -603,12 +592,11 @@ pub fn setup_initial_nostrdb_subs(
|
||||
ndb: &Ndb,
|
||||
note_cache: &mut NoteCache,
|
||||
decks_cache: &mut DecksCache,
|
||||
is_muted: &MuteFun,
|
||||
) -> Result<()> {
|
||||
for decks in decks_cache.get_all_decks_mut() {
|
||||
for deck in decks.decks_mut() {
|
||||
for timeline in deck.columns_mut().timelines_mut() {
|
||||
if let Err(err) = setup_timeline_nostrdb_sub(ndb, note_cache, timeline, is_muted) {
|
||||
if let Err(err) = setup_timeline_nostrdb_sub(ndb, note_cache, timeline) {
|
||||
error!("setup_initial_nostrdb_subs: {err}");
|
||||
}
|
||||
}
|
||||
@@ -622,7 +610,6 @@ fn setup_timeline_nostrdb_sub(
|
||||
ndb: &Ndb,
|
||||
note_cache: &mut NoteCache,
|
||||
timeline: &mut Timeline,
|
||||
is_muted: &MuteFun,
|
||||
) -> Result<()> {
|
||||
let filter_state = timeline
|
||||
.filter
|
||||
@@ -630,7 +617,7 @@ fn setup_timeline_nostrdb_sub(
|
||||
.ok_or(Error::App(notedeck::Error::empty_contact_list()))?
|
||||
.to_owned();
|
||||
|
||||
setup_initial_timeline(ndb, timeline, note_cache, &filter_state, is_muted)?;
|
||||
setup_initial_timeline(ndb, timeline, note_cache, &filter_state)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -644,7 +631,6 @@ pub fn is_timeline_ready(
|
||||
pool: &mut RelayPool,
|
||||
note_cache: &mut NoteCache,
|
||||
timeline: &mut Timeline,
|
||||
is_muted: &MuteFun,
|
||||
our_pk: Option<&Pubkey>,
|
||||
) -> bool {
|
||||
// TODO: we should debounce the filter states a bit to make sure we have
|
||||
@@ -705,8 +691,7 @@ pub fn is_timeline_ready(
|
||||
// we just switched to the ready state, we should send initial
|
||||
// queries and setup the local subscription
|
||||
info!("Found contact list! Setting up local and remote contact list query");
|
||||
setup_initial_timeline(ndb, timeline, note_cache, &filter, is_muted)
|
||||
.expect("setup init");
|
||||
setup_initial_timeline(ndb, timeline, note_cache, &filter).expect("setup init");
|
||||
timeline
|
||||
.filter
|
||||
.set_relay_state(relay_id, FilterState::ready(filter.clone()));
|
||||
|
||||
@@ -63,6 +63,7 @@ pub fn render_timeline_route(
|
||||
note_cache,
|
||||
img_cache,
|
||||
note_options,
|
||||
&accounts.mutefun(),
|
||||
)
|
||||
.ui(ui);
|
||||
|
||||
@@ -77,9 +78,10 @@ pub fn render_timeline_route(
|
||||
img_cache,
|
||||
id.bytes(),
|
||||
textmode,
|
||||
&accounts.mutefun(),
|
||||
)
|
||||
.id_source(egui::Id::new(("threadscroll", col)))
|
||||
.ui(ui, &accounts.mutefun())
|
||||
.ui(ui)
|
||||
.map(Into::into),
|
||||
|
||||
TimelineRoute::Reply(id) => {
|
||||
@@ -173,9 +175,10 @@ pub fn render_profile_route(
|
||||
ndb,
|
||||
note_cache,
|
||||
img_cache,
|
||||
is_muted,
|
||||
NoteOptions::default(),
|
||||
)
|
||||
.ui(ui, is_muted);
|
||||
.ui(ui);
|
||||
|
||||
if let Some(action) = action {
|
||||
match action {
|
||||
|
||||
Reference in New Issue
Block a user