Flexible routing
Another massive refactor to change the way routing works. Now any column can route anywhere. Also things are generally just much better and more modular via the new struct split borrowing technique. I didn't even try to split this into smaller commits for my sanity. Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
use crate::column::Columns;
|
||||
use crate::notecache::{CachedNote, NoteCache};
|
||||
use crate::timeline::ViewFilter;
|
||||
use crate::Result;
|
||||
use crate::{
|
||||
column::Columns,
|
||||
note::NoteRef,
|
||||
notecache::{CachedNote, NoteCache},
|
||||
timeline::ViewFilter,
|
||||
Result,
|
||||
};
|
||||
|
||||
use enostr::{Filter, NoteId, Pubkey};
|
||||
use nostrdb::{BlockType, Mention, Ndb, Note, NoteKey, Transaction};
|
||||
use std::collections::HashSet;
|
||||
@@ -64,6 +68,35 @@ impl UnknownIds {
|
||||
self.last_updated = Some(now);
|
||||
}
|
||||
|
||||
pub fn update_from_note_key(
|
||||
txn: &Transaction,
|
||||
ndb: &Ndb,
|
||||
unknown_ids: &mut UnknownIds,
|
||||
note_cache: &mut NoteCache,
|
||||
key: NoteKey,
|
||||
) -> bool {
|
||||
let note = if let Ok(note) = ndb.get_note_by_key(txn, key) {
|
||||
note
|
||||
} else {
|
||||
return false;
|
||||
};
|
||||
|
||||
UnknownIds::update_from_note(txn, ndb, unknown_ids, note_cache, ¬e)
|
||||
}
|
||||
|
||||
/// Should be called on freshly polled notes from subscriptions
|
||||
pub fn update_from_note_refs(
|
||||
txn: &Transaction,
|
||||
ndb: &Ndb,
|
||||
unknown_ids: &mut UnknownIds,
|
||||
note_cache: &mut NoteCache,
|
||||
note_refs: &[NoteRef],
|
||||
) {
|
||||
for note_ref in note_refs {
|
||||
Self::update_from_note_key(txn, ndb, unknown_ids, note_cache, note_ref.key);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn update_from_note(
|
||||
txn: &Transaction,
|
||||
ndb: &Ndb,
|
||||
|
||||
Reference in New Issue
Block a user