mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 11:43:43 +00:00
Move failed_avatars list so we can remove items from it when metadata is updated
This commit is contained in:
parent
e64c85a5ea
commit
f991e4e801
@ -7,9 +7,9 @@ use crate::people::People;
|
||||
use crate::relationship::Relationship;
|
||||
use crate::settings::Settings;
|
||||
use crate::signer::Signer;
|
||||
use nostr_types::{Event, Id, IdHex, Unixtime, Url};
|
||||
use nostr_types::{Event, Id, IdHex, PublicKeyHex, Unixtime, Url};
|
||||
use rusqlite::Connection;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::atomic::AtomicBool;
|
||||
use tokio::sync::{broadcast, mpsc, Mutex, RwLock};
|
||||
use tracing::info;
|
||||
@ -76,6 +76,9 @@ pub struct Globals {
|
||||
|
||||
/// Fetcher
|
||||
pub fetcher: Fetcher,
|
||||
|
||||
/// Failed Avatar Fetches
|
||||
pub failed_avatars: RwLock<HashSet<PublicKeyHex>>,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
@ -106,6 +109,7 @@ lazy_static! {
|
||||
event_is_new: RwLock::new(Vec::new()),
|
||||
feed: Mutex::new(Feed::new()),
|
||||
fetcher: Fetcher::new(),
|
||||
failed_avatars: RwLock::new(HashSet::new()),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -123,6 +123,9 @@ impl People {
|
||||
})
|
||||
.await??;
|
||||
|
||||
// Remove from failed avatars list so the UI will try to fetch the avatar again
|
||||
GLOBALS.failed_avatars.write().await.remove(pubkeyhex);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ use egui::{
|
||||
TextureOptions, Ui,
|
||||
};
|
||||
use nostr_types::{Id, PublicKey, PublicKeyHex};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashMap;
|
||||
use std::time::{Duration, Instant};
|
||||
use zeroize::Zeroize;
|
||||
|
||||
@ -89,7 +89,6 @@ struct GossipUi {
|
||||
person_view_person: Option<DbPerson>,
|
||||
person_view_name: Option<String>,
|
||||
avatars: HashMap<PublicKeyHex, TextureHandle>,
|
||||
failed_avatars: HashSet<PublicKeyHex>,
|
||||
new_relay_url: String,
|
||||
}
|
||||
|
||||
@ -165,7 +164,6 @@ impl GossipUi {
|
||||
person_view_person: None,
|
||||
person_view_name: None,
|
||||
avatars: HashMap::new(),
|
||||
failed_avatars: HashSet::new(),
|
||||
new_relay_url: "".to_owned(),
|
||||
}
|
||||
}
|
||||
@ -287,7 +285,7 @@ impl GossipUi {
|
||||
pubkeyhex: &PublicKeyHex,
|
||||
) -> Option<TextureHandle> {
|
||||
// Do not keep retrying if failed
|
||||
if self.failed_avatars.contains(pubkeyhex) {
|
||||
if GLOBALS.failed_avatars.blocking_read().contains(pubkeyhex) {
|
||||
return None;
|
||||
}
|
||||
|
||||
@ -297,7 +295,10 @@ impl GossipUi {
|
||||
|
||||
match GLOBALS.people.blocking_write().get_avatar(pubkeyhex) {
|
||||
Err(_) => {
|
||||
self.failed_avatars.insert(pubkeyhex.to_owned());
|
||||
GLOBALS
|
||||
.failed_avatars
|
||||
.blocking_write()
|
||||
.insert(pubkeyhex.to_owned());
|
||||
None
|
||||
}
|
||||
Ok(Some(rgbaimage)) => {
|
||||
|
Loading…
Reference in New Issue
Block a user