When unfollowing someone, remove them from the relay picker

This commit is contained in:
Mike Dilger 2023-02-24 08:09:12 +13:00
parent cb79b75fb3
commit e1365d6c5a
2 changed files with 21 additions and 3 deletions

View File

@ -690,8 +690,12 @@ impl People {
} }
} }
// Add the person to the relay_tracker for picking if follow > 0 {
GLOBALS.relay_tracker.add_someone(pubkeyhex.to_owned())?; // Add the person to the relay_tracker for picking
GLOBALS.relay_tracker.add_someone(pubkeyhex.to_owned())?;
} else {
GLOBALS.relay_tracker.remove_someone(pubkeyhex.to_owned());
}
Ok(()) Ok(())
} }

View File

@ -133,7 +133,21 @@ impl RelayTracker {
Ok(()) Ok(())
} }
// We could do 'remove_someone' but that's less important. People can just restart. pub fn remove_someone(&self, pubkey: PublicKeyHex) {
// Remove from pubkey counts
self.pubkey_counts.remove(&pubkey);
// Remove from relay assignments
for mut elem in self.relay_assignments.iter_mut() {
let assignment = elem.value_mut();
if let Some(pos) = assignment.pubkeys.iter().position(|x| x == &pubkey) {
assignment.pubkeys.remove(pos);
}
}
// This doesn't indicate that the assignment has changed, so the relay is
// still delivering their events. But the feed shouldn't be showing them.
}
pub async fn refresh_person_relay_scores(&self, initialize_counts: bool) -> Result<(), Error> { pub async fn refresh_person_relay_scores(&self, initialize_counts: bool) -> Result<(), Error> {
self.person_relay_scores.clear(); self.person_relay_scores.clear();