feat: add tracking for which signer encrypted the message #27
@@ -578,6 +578,10 @@ impl ChatRegistry {
|
|||||||
/// Reset the registry.
|
/// Reset the registry.
|
||||||
pub fn reset(&mut self, cx: &mut Context<Self>) {
|
pub fn reset(&mut self, cx: &mut Context<Self>) {
|
||||||
self.rooms.clear();
|
self.rooms.clear();
|
||||||
|
self.trashes.update(cx, |this, cx| {
|
||||||
|
this.clear();
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -471,6 +471,12 @@ impl ChatPanel {
|
|||||||
self.reports_by_id.read(cx).get(id).is_some()
|
self.reports_by_id.read(cx).get(id).is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check if a message was encrypted by the dekey
|
||||||
|
fn encrypted_by_dekey(&self, id: &EventId, cx: &App) -> bool {
|
||||||
|
let chat = ChatRegistry::global(cx);
|
||||||
|
chat.read(cx).encrypted_by_dekey(id)
|
||||||
|
}
|
||||||
|
|
||||||
/// Get all sent reports for a message by its ID
|
/// Get all sent reports for a message by its ID
|
||||||
fn sent_reports(&self, id: &EventId, cx: &App) -> Option<Vec<SendReport>> {
|
fn sent_reports(&self, id: &EventId, cx: &App) -> Option<Vec<SendReport>> {
|
||||||
self.reports_by_id.read(cx).get(id).cloned()
|
self.reports_by_id.read(cx).get(id).cloned()
|
||||||
@@ -843,6 +849,7 @@ impl ChatPanel {
|
|||||||
let replies = message.replies_to.as_slice();
|
let replies = message.replies_to.as_slice();
|
||||||
let has_replies = !replies.is_empty();
|
let has_replies = !replies.is_empty();
|
||||||
let has_reports = self.has_reports(&id, cx);
|
let has_reports = self.has_reports(&id, cx);
|
||||||
|
let encrypted_by_dekey = self.encrypted_by_dekey(&id, cx);
|
||||||
|
|
||||||
// Hide avatar setting
|
// Hide avatar setting
|
||||||
let hide_avatar = AppSettings::get_hide_avatar(cx);
|
let hide_avatar = AppSettings::get_hide_avatar(cx);
|
||||||
@@ -888,6 +895,17 @@ impl ChatPanel {
|
|||||||
.text_color(cx.theme().text)
|
.text_color(cx.theme().text)
|
||||||
.child(author.name()),
|
.child(author.name()),
|
||||||
)
|
)
|
||||||
|
.when(encrypted_by_dekey, |this| {
|
||||||
|
this.child(
|
||||||
|
Button::new(format!("dekey-{ix}"))
|
||||||
|
.icon(IconName::Shield)
|
||||||
|
.ghost()
|
||||||
|
.xsmall()
|
||||||
|
.px_4()
|
||||||
|
.tooltip("Encrypted by Dekey")
|
||||||
|
.disabled(true),
|
||||||
|
)
|
||||||
|
})
|
||||||
.child(message.created_at.to_human_time())
|
.child(message.created_at.to_human_time())
|
||||||
.when(has_reports, |this| {
|
.when(has_reports, |this| {
|
||||||
this.child(deferred(self.render_sent_reports(&id, cx)))
|
this.child(deferred(self.render_sent_reports(&id, cx)))
|
||||||
|
|||||||
Reference in New Issue
Block a user