add web of trust score to profile dialog

This commit is contained in:
2026-10-20 10:58:32 +07:00
parent 9143de6cfe
commit 0f0216051f
4 changed files with 28 additions and 6 deletions
+5
View File
@@ -455,6 +455,11 @@ impl WebOfTrust {
self.ready
}
/// Whether the graph is loaded and score queries are meaningful
pub fn is_loaded(&self) -> bool {
self.ready && !self.disabled
}
/// Whether scoring is disabled due to an oversized follow set
pub fn is_disabled(&self) -> bool {
self.disabled
+16 -1
View File
@@ -9,7 +9,7 @@ use gpui::{
};
use instant::Duration;
use nostr_sdk::prelude::*;
use person::{Directory, Person, PersonRegistry, shorten_pubkey};
use person::{Directory, Person, PersonRegistry, WebOfTrust, shorten_pubkey};
use settings::AppSettings;
use state::{NostrRegistry, upload};
use theme::{ActiveTheme, TextStyle, Typeset as _, button_radius};
@@ -459,9 +459,24 @@ impl Render for ProfileDialog {
.filter(|website| !website.trim().is_empty())
.map(SharedString::from);
let score = {
let wot = WebOfTrust::global(cx).read(cx);
wot.is_loaded().then(|| wot.score(&self.public_key))
}
.map(|score| {
SharedString::from(format!(
"{} mutual {}",
score,
if score == 1 { "contact" } else { "contacts" }
))
});
this.child(field("Name", name, "Unknown", cx))
.child(field("About", about, "No bio", cx))
.child(field("Website", website, "No website", cx))
.when(!self.is_current_user, |this| {
this.child(field("Web of Trust", score, "Not loaded yet", cx))
})
})
.child(
h_flex()
+3 -3
View File
@@ -126,7 +126,7 @@ impl Screening {
fn check_wot(&mut self, cx: &mut Context<Self>) {
let trusted = {
let wot = WebOfTrust::global(cx).read(cx);
(wot.is_ready() && !wot.is_disabled()).then(|| wot.mutuals(&self.public_key))
wot.is_loaded().then(|| wot.mutuals(&self.public_key))
};
if let Some(contacts) = trusted {
@@ -166,11 +166,11 @@ impl Screening {
let contacts = task.await;
this.update(cx, |this, cx| {
let wot = WebOfTrust::global(cx).read(cx);
// The web of trust wins once its load has finished
if wot.is_ready() && !wot.is_disabled() {
if WebOfTrust::global(cx).read(cx).is_loaded() {
return;
}
this.mutual_contacts = contacts;
cx.notify();
})
+4 -2
View File
@@ -150,8 +150,10 @@ Status: **partially implemented**. Request rooms whose members are all outside
the web of trust show a `SPAM` badge in the sidebar
(`Room::is_spam` + `WebOfTrust::is_outside`, rendered in
`crates/workspace/src/sidebar/rows.rs`; the sidebar subscribes to `WoTEvent` so
badges update when the graph loads). The mutual-count caption below is still
open and will follow a different flow.
badges update when the graph loads). The profile dialog shows the score as a
"Web of Trust" field (`crates/workspace/src/dialogs/profile.rs`, other users
only). The mutual-count caption below is still open and will follow a
different flow.
Where request rooms are rendered, show the mutual count for the sender: