Fix the "I cannot find you" issue by asynchronously creating

This commit is contained in:
Mike Dilger 2023-02-11 10:58:46 +13:00
parent b96cd1fb5a
commit d5d1f2fee3
2 changed files with 9 additions and 0 deletions

View File

@ -165,6 +165,14 @@ impl People {
output
}
pub fn create_if_missing_sync(&self, pubkey: PublicKeyHex) {
task::spawn(async {
if let Err(e) = GLOBALS.people.create_all_if_missing(&[pubkey]).await {
tracing::error!("{}", e);
}
});
}
pub async fn create_all_if_missing(&self, pubkeys: &[PublicKeyHex]) -> Result<(), Error> {
// Collect the public keys that we don't have already (by checking in memory).
let pubkeys: Vec<&PublicKeyHex> = pubkeys

View File

@ -32,6 +32,7 @@ pub(super) fn update(app: &mut GossipUi, _ctx: &Context, _frame: &mut eframe::Fr
Some(dbp) => dbp,
None => {
ui.label("I cannot find you.");
GLOBALS.people.create_if_missing_sync(public_key.into());
return;
}
};