fix: Emit AccountsItemChanged when own key is generated/imported, use gray self-color until that (#7296)

Emitting an `AccountsItemChanged` event is needed for UIs to know when `Contact::get_color()` starts
returning the true color for `SELF`. Before, an address-based color was returned for a new account
which was changing to a fingerprint-based color e.g. on app restart. Now the self-color is our
favorite gray until own keypair is generated or imported e.g. via ASM.
This commit is contained in:
iequidoo
2025-10-10 14:59:22 -03:00
committed by iequidoo
parent 2d7dc7a1be
commit 0e47e89d63
3 changed files with 21 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ use rand::thread_rng;
use tokio::runtime::Handle;
use crate::context::Context;
use crate::events::EventType;
use crate::log::{LogExt, info};
use crate::pgp::KeyPair;
use crate::tools::{self, time_elapsed};
@@ -414,15 +415,11 @@ pub(crate) async fn store_self_keypair(context: &Context, keypair: &KeyPair) ->
"INSERT INTO config (keyname, value) VALUES ('key_id', ?)",
(new_key_id,),
)?;
Ok(Some(new_key_id))
Ok(new_key_id)
})
.await?;
if let Some(new_key_id) = new_key_id {
// Update config cache if transaction succeeded and changed current default key.
config_cache_lock.insert("key_id".to_string(), Some(new_key_id.to_string()));
}
context.emit_event(EventType::AccountsItemChanged);
config_cache_lock.insert("key_id".to_string(), Some(new_key_id.to_string()));
Ok(())
}