Skip to content

Commit

Permalink
remove ProfileState from cache once sent
Browse files Browse the repository at this point in the history
Signed-off-by: kernelkind <[email protected]>
  • Loading branch information
kernelkind committed Jan 4, 2025
1 parent 6645d48 commit 05ab117
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions crates/notedeck_columns/src/nav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ impl RenderNavResponse {
}
RenderNavAction::ProfileAction(profile_action) => {
profile_action.process(
&mut app.view_state.pubkey_to_profile_state,
ctx.ndb,
ctx.pool,
get_active_columns_mut(ctx.accounts, &mut app.decks_cache)
Expand Down
11 changes: 10 additions & 1 deletion crates/notedeck_columns/src/profile.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::HashMap;

use enostr::{Filter, FullKeypair, Pubkey, RelayPool};
use nostrdb::{
FilterBuilder, Ndb, Note, NoteBuildOptions, NoteBuilder, ProfileRecord, Transaction,
Expand Down Expand Up @@ -194,7 +196,13 @@ pub enum ProfileAction {
}

impl ProfileAction {
pub fn process(&self, ndb: &Ndb, pool: &mut RelayPool, router: &mut Router<Route>) {
pub fn process(
&self,
state_map: &mut HashMap<Pubkey, ProfileState>,
ndb: &Ndb,
pool: &mut RelayPool,
router: &mut Router<Route>,
) {
match self {
ProfileAction::Edit(kp) => {
router.route_to(Route::EditProfile(kp.pubkey));
Expand All @@ -203,6 +211,7 @@ impl ProfileAction {
let raw_msg = format!("[\"EVENT\",{}]", changes.to_note().json().unwrap());

let _ = ndb.process_client_event(raw_msg.as_str());
let _ = state_map.remove_entry(&changes.kp.pubkey);

info!("sending {}", raw_msg);
pool.send(&enostr::ClientMessage::raw(raw_msg));
Expand Down

0 comments on commit 05ab117

Please sign in to comment.