integrate EditProfileView

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-01-03 17:50:48 -05:00
parent 3384d2af14
commit 6645d4880f
7 changed files with 137 additions and 15 deletions

View File

@@ -1,12 +1,16 @@
use enostr::{Filter, FullKeypair, Pubkey};
use nostrdb::{FilterBuilder, Ndb, Note, NoteBuilder, ProfileRecord, Transaction};
use enostr::{Filter, FullKeypair, Pubkey, RelayPool};
use nostrdb::{
FilterBuilder, Ndb, Note, NoteBuildOptions, NoteBuilder, ProfileRecord, Transaction,
};
use notedeck::{filter::default_limit, FilterState, MuteFun, NoteCache, NoteRef};
use tracing::info;
use crate::{
multi_subscriber::MultiSubscriber,
notes_holder::NotesHolder,
profile_state::ProfileState,
route::{Route, Router},
timeline::{copy_notes_into_timeline, PubkeySource, Timeline, TimelineKind, TimelineTab},
};
@@ -171,7 +175,7 @@ impl SaveProfileChanges {
add_client_tag(NoteBuilder::new())
.kind(0)
.content(&self.state.to_json())
.sign(sec)
.options(NoteBuildOptions::default().created_at(true).sign(sec))
.build()
.expect("should build")
}
@@ -188,3 +192,23 @@ pub enum ProfileAction {
Edit(FullKeypair),
SaveChanges(SaveProfileChanges),
}
impl ProfileAction {
pub fn process(&self, ndb: &Ndb, pool: &mut RelayPool, router: &mut Router<Route>) {
match self {
ProfileAction::Edit(kp) => {
router.route_to(Route::EditProfile(kp.pubkey));
}
ProfileAction::SaveChanges(changes) => {
let raw_msg = format!("[\"EVENT\",{}]", changes.to_note().json().unwrap());
let _ = ndb.process_client_event(raw_msg.as_str());
info!("sending {}", raw_msg);
pool.send(&enostr::ClientMessage::raw(raw_msg));
router.go_back();
}
}
}
}