upgrade TimelineOpenResult to hold new pubkeys too
for handling unknown profiles Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
column::Columns,
|
column::Columns,
|
||||||
nav::{RouterAction, RouterType},
|
nav::{RouterAction, RouterType},
|
||||||
@@ -28,8 +30,9 @@ pub enum NotesOpenResult {
|
|||||||
Thread(NewThreadNotes),
|
Thread(NewThreadNotes),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum TimelineOpenResult {
|
pub struct TimelineOpenResult {
|
||||||
NewNotes(NewNotes),
|
new_notes: Option<NewNotes>,
|
||||||
|
new_pks: Option<HashSet<Pubkey>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NoteActionResponse {
|
struct NoteActionResponse {
|
||||||
@@ -268,7 +271,24 @@ fn clear_zap_error(sender: &Pubkey, zaps: &mut Zaps, target: &NoteZapTargetOwned
|
|||||||
|
|
||||||
impl TimelineOpenResult {
|
impl TimelineOpenResult {
|
||||||
pub fn new_notes(notes: Vec<NoteKey>, id: TimelineKind) -> Self {
|
pub fn new_notes(notes: Vec<NoteKey>, id: TimelineKind) -> Self {
|
||||||
Self::NewNotes(NewNotes::new(notes, id))
|
Self {
|
||||||
|
new_notes: Some(NewNotes { id, notes }),
|
||||||
|
new_pks: None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_pks(pks: HashSet<Pubkey>) -> Self {
|
||||||
|
Self {
|
||||||
|
new_notes: None,
|
||||||
|
new_pks: Some(pks),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert_pks(&mut self, pks: HashSet<Pubkey>) {
|
||||||
|
match &mut self.new_pks {
|
||||||
|
Some(cur_pks) => cur_pks.extend(pks),
|
||||||
|
None => self.new_pks = Some(pks),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process(
|
pub fn process(
|
||||||
@@ -279,11 +299,17 @@ impl TimelineOpenResult {
|
|||||||
storage: &mut TimelineCache,
|
storage: &mut TimelineCache,
|
||||||
unknown_ids: &mut UnknownIds,
|
unknown_ids: &mut UnknownIds,
|
||||||
) {
|
) {
|
||||||
match self {
|
// update the thread for next render if we have new notes
|
||||||
// update the thread for next render if we have new notes
|
if let Some(new_notes) = &self.new_notes {
|
||||||
TimelineOpenResult::NewNotes(new_notes) => {
|
new_notes.process(storage, ndb, txn, unknown_ids, note_cache);
|
||||||
new_notes.process(storage, ndb, txn, unknown_ids, note_cache);
|
}
|
||||||
}
|
|
||||||
|
let Some(pks) = &self.new_pks else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
for pk in pks {
|
||||||
|
unknown_ids.add_pubkey_if_missing(ndb, txn, pk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user