Skip muted content
This commit is contained in:
@@ -5,7 +5,7 @@ use nostrdb::{Ndb, Transaction};
|
||||
use tracing::{debug, info, warn};
|
||||
|
||||
use crate::{
|
||||
actionbar::NotesHolderResult, multi_subscriber::MultiSubscriber, note::NoteRef,
|
||||
actionbar::NotesHolderResult, multi_subscriber::MultiSubscriber, muted::MuteFun, note::NoteRef,
|
||||
notecache::NoteCache, timeline::TimelineTab, unknowns::NoteRefsUnkIdAction, Error, Result,
|
||||
};
|
||||
|
||||
@@ -55,6 +55,7 @@ impl<M: NotesHolder> NotesHolderStorage<M> {
|
||||
note_cache: &mut NoteCache,
|
||||
txn: &Transaction,
|
||||
id: &[u8; 32],
|
||||
is_muted: &MuteFun,
|
||||
) -> Vitality<'a, M> {
|
||||
// we can't use the naive hashmap entry API here because lookups
|
||||
// require a copy, wait until we have a raw entry api. We could
|
||||
@@ -88,7 +89,7 @@ impl<M: NotesHolder> NotesHolderStorage<M> {
|
||||
|
||||
self.id_to_object.insert(
|
||||
id.to_owned(),
|
||||
M::new_notes_holder(txn, ndb, note_cache, id, M::filters(id), notes),
|
||||
M::new_notes_holder(txn, ndb, note_cache, id, M::filters(id), notes, is_muted),
|
||||
);
|
||||
Vitality::Fresh(self.id_to_object.get_mut(id).unwrap())
|
||||
}
|
||||
@@ -107,6 +108,7 @@ pub trait NotesHolder {
|
||||
id: &[u8; 32],
|
||||
filters: Vec<Filter>,
|
||||
notes: Vec<NoteRef>,
|
||||
is_muted: &MuteFun,
|
||||
) -> Self;
|
||||
|
||||
#[must_use = "process_action must be handled in the Ok(action) case"]
|
||||
@@ -114,10 +116,11 @@ pub trait NotesHolder {
|
||||
&mut self,
|
||||
txn: &Transaction,
|
||||
ndb: &Ndb,
|
||||
is_muted: &MuteFun,
|
||||
) -> Result<NoteRefsUnkIdAction> {
|
||||
if let Some(multi_subscriber) = self.get_multi_subscriber() {
|
||||
let reversed = true;
|
||||
let note_refs: Vec<NoteRef> = multi_subscriber.poll_for_notes(ndb, txn)?;
|
||||
let note_refs: Vec<NoteRef> = multi_subscriber.poll_for_notes(ndb, txn, is_muted)?;
|
||||
self.get_view().insert(¬e_refs, reversed);
|
||||
Ok(NoteRefsUnkIdAction::new(note_refs))
|
||||
} else {
|
||||
@@ -156,9 +159,10 @@ pub trait NotesHolder {
|
||||
notes_holder_storage: &mut NotesHolderStorage<M>,
|
||||
pool: &mut RelayPool,
|
||||
id: &[u8; 32],
|
||||
is_muted: &MuteFun,
|
||||
) {
|
||||
let notes_holder = notes_holder_storage
|
||||
.notes_holder_mutated(ndb, note_cache, txn, id)
|
||||
.notes_holder_mutated(ndb, note_cache, txn, id, is_muted)
|
||||
.get_ptr();
|
||||
|
||||
if let Some(multi_subscriber) = notes_holder.get_multi_subscriber() {
|
||||
@@ -173,8 +177,9 @@ pub trait NotesHolder {
|
||||
pool: &mut RelayPool,
|
||||
storage: &mut NotesHolderStorage<M>,
|
||||
id: &[u8; 32],
|
||||
is_muted: &MuteFun,
|
||||
) -> Option<NotesHolderResult> {
|
||||
let vitality = storage.notes_holder_mutated(ndb, note_cache, txn, id);
|
||||
let vitality = storage.notes_holder_mutated(ndb, note_cache, txn, id, is_muted);
|
||||
|
||||
let (holder, result) = match vitality {
|
||||
Vitality::Stale(holder) => {
|
||||
|
||||
Reference in New Issue
Block a user