mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Update metadata button (under a menu so it's not too easy to click often)
This commit is contained in:
parent
0eec4fad80
commit
605fa54a37
@ -524,6 +524,43 @@ impl Overlord {
|
|||||||
DbRelay::insert(dbrelay).await?;
|
DbRelay::insert(dbrelay).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"update_metadata" => {
|
||||||
|
tracing::debug!("Overlord got update_metadata request");
|
||||||
|
|
||||||
|
// Get all people we are rendering
|
||||||
|
let v: Vec<PublicKeyHex> = GLOBALS.people.read().await
|
||||||
|
.get_all().iter().map(|p| p.pubkey.clone()).collect();
|
||||||
|
|
||||||
|
// Get all relays we are connected to
|
||||||
|
let r: Vec<String> = self.urls_watching.iter().map(|u| u.inner().to_owned()).collect();
|
||||||
|
|
||||||
|
// Match up people with relays, sorted into per-relay buckets
|
||||||
|
let matching = DbPersonRelay::fetch_matching(v.clone(), r.clone()).await?;
|
||||||
|
let mut by_relay: HashMap<String, Vec<PublicKeyHex>> = HashMap::new();
|
||||||
|
for person_relay in matching.iter() {
|
||||||
|
let pkh = PublicKeyHex(person_relay.person.clone());
|
||||||
|
by_relay.entry(person_relay.relay.clone())
|
||||||
|
.and_modify(|v| v.push(pkh.clone()))
|
||||||
|
.or_insert_with(|| {
|
||||||
|
vec![pkh]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tell each minion in turn to subscribe to ephemeral data for all
|
||||||
|
// the people we are watching that use that relay
|
||||||
|
for (relay, people) in by_relay.iter() {
|
||||||
|
|
||||||
|
tracing::debug!("Overlord asking {} to update metadata for {} people",
|
||||||
|
&relay, people.len());
|
||||||
|
|
||||||
|
// "subscribe_ephemeral_for_all"
|
||||||
|
let _ = self.to_minions.send(BusMessage {
|
||||||
|
target: relay.to_string(),
|
||||||
|
kind: "subscribe_ephemeral_for_all".to_string(),
|
||||||
|
json_payload: serde_json::to_string(people).unwrap(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
},
|
},
|
||||||
_ => {}
|
_ => {}
|
||||||
|
@ -195,7 +195,7 @@ impl People {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_all(&mut self) -> Vec<DbPerson> {
|
pub fn get_all(&self) -> Vec<DbPerson> {
|
||||||
let mut v: Vec<DbPerson> = self.people.values().map(|p| p.to_owned()).collect();
|
let mut v: Vec<DbPerson> = self.people.values().map(|p| p.to_owned()).collect();
|
||||||
v.sort_by(|a, b| {
|
v.sort_by(|a, b| {
|
||||||
let c = a.name.cmp(&b.name);
|
let c = a.name.cmp(&b.name);
|
||||||
|
@ -31,21 +31,35 @@ pub(super) fn update(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
|
|||||||
};
|
};
|
||||||
|
|
||||||
ui.with_layout(Layout::right_to_left(Align::TOP), |ui| {
|
ui.with_layout(Layout::right_to_left(Align::TOP), |ui| {
|
||||||
if ui
|
|
||||||
.button(&format!("QM {}", desired_count))
|
ui.menu_button("Query", |ui| {
|
||||||
|
if ui.button("Missing Events")
|
||||||
.on_hover_text("Query Relays for Missing Events")
|
.on_hover_text("Query Relays for Missing Events")
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
let tx = GLOBALS.to_overlord.clone();
|
let _ = GLOBALS.to_overlord.send(BusMessage {
|
||||||
let _ = tx.send(BusMessage {
|
|
||||||
target: "overlord".to_string(),
|
target: "overlord".to_string(),
|
||||||
kind: "get_missing_events".to_string(),
|
kind: "get_missing_events".to_string(),
|
||||||
json_payload: serde_json::to_string("").unwrap(),
|
json_payload: serde_json::to_string("").unwrap(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ui.button("Metadata")
|
||||||
|
.on_hover_text("Metadata and contact lists for everyone in the feed")
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
let _ = GLOBALS.to_overlord.send(BusMessage {
|
||||||
|
target: "overlord".to_string(),
|
||||||
|
kind: "update_metadata".to_string(),
|
||||||
|
json_payload: serde_json::to_string("").unwrap(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.label(&format!("Missing={}", desired_count));
|
||||||
|
|
||||||
if ui
|
if ui
|
||||||
.button(&format!("PQ {}", incoming_count))
|
.button(&format!("Process={}", incoming_count))
|
||||||
.on_hover_text("Process Queue of Incoming Events")
|
.on_hover_text("Process Queue of Incoming Events")
|
||||||
.clicked()
|
.clicked()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user