This commit is contained in:
Ren Amamiya
2026-03-31 12:25:05 +07:00
parent c1b0b81e25
commit e9809ccfc7
2 changed files with 49 additions and 4 deletions

View File

@@ -468,7 +468,15 @@ impl ChatRegistry {
self.trashes.clone()
}
/// Get the relays that have seen a given message.
/// Get the relays that have seen a given rumor id.
pub fn rumor_seen_on(&self, id: &EventId) -> Option<HashSet<RelayUrl>> {
self.event_map
.read_blocking()
.get(id)
.map(|id| self.seen_on(id))
}
/// Get the relays that have seen a given gift wrap id.
pub fn seen_on(&self, id: &EventId) -> HashSet<RelayUrl> {
self.seens
.read_blocking()

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
pub use actions::*;
use anyhow::{Context as AnyhowContext, Error};
use chat::{Message, RenderedMessage, Room, RoomEvent, SendReport, SendStatus};
use chat::{ChatRegistry, Message, RenderedMessage, Room, RoomEvent, SendReport, SendStatus};
use common::RenderedTimestamp;
use gpui::prelude::FluentBuilder;
use gpui::{
@@ -665,9 +665,46 @@ impl ChatPanel {
}
fn open_trace(&mut self, id: &EventId, window: &mut Window, cx: &mut Context<Self>) {
let chat = ChatRegistry::global(cx);
let seen_on = chat.read(cx).rumor_seen_on(id);
window.open_modal(cx, move |this, _window, cx| {
// TODO
this.child(v_flex().child(""))
this.title("Seen on").show_close(true).child(
v_flex()
.gap_1()
.when_none(&seen_on, |this| {
this.child(
h_flex()
.h_10()
.justify_center()
.text_sm()
.bg(cx.theme().elevated_surface_background)
.rounded(cx.theme().radius)
.child("Message isn't traced yet"),
)
})
.when_some(seen_on.as_ref(), |this, relays| {
this.children({
let mut items = vec![];
for url in relays.iter() {
items.push(
h_flex()
.h_7()
.px_2()
.gap_2()
.bg(cx.theme().elevated_surface_background)
.rounded(cx.theme().radius)
.text_sm()
.child(div().size_1p5().rounded_full().bg(gpui::green()))
.child(SharedString::from(url.to_string())),
);
}
items
})
}),
)
});
}