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
+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();
})