feat: better summary for calls

This commit is contained in:
link2xt
2025-09-26 18:13:18 +00:00
committed by l
parent a930ae27be
commit 9f0ba4b9c2
2 changed files with 20 additions and 4 deletions

View File

@@ -398,6 +398,11 @@ async fn test_caller_cancels_call() -> Result<()> {
.await;
assert_eq!(call_state(&bob, bob_call.id).await?, CallState::Missed);
// Test that message summary says it is a missed call.
let bob_call_msg = Message::load_from_db(&bob, bob_call.id).await?;
let summary = bob_call_msg.get_summary(&bob, None).await?;
assert_eq!(summary.text, "📞 Missed Call");
bob2.recv_msg_trash(&sent3).await;
assert_text(&bob2, bob2_call.id, "Missed call").await?;
bob2.evtracker

View File

@@ -4,6 +4,7 @@ use std::borrow::Cow;
use std::fmt;
use std::str;
use crate::calls::{CallState, call_state};
use crate::chat::Chat;
use crate::constants::Chattype;
use crate::contact::{Contact, ContactId};
@@ -234,11 +235,21 @@ impl Message {
append_text = true;
}
Viewtype::Call => {
let call_state = call_state(context, self.id)
.await
.unwrap_or(CallState::Alerting);
emoji = Some("📞");
type_name = Some(if self.from_id == ContactId::SELF {
"Outgoing call".to_string()
} else {
"Incoming call".to_string()
type_name = Some(match call_state {
CallState::Alerting | CallState::Active | CallState::Completed { .. } => {
if self.from_id == ContactId::SELF {
stock_str::outgoing_call(context).await
} else {
stock_str::incoming_call(context).await
}
}
CallState::Missed => stock_str::missed_call(context).await,
CallState::Declined => stock_str::declined_call(context).await,
CallState::Canceled => stock_str::canceled_call(context).await,
});
type_file = None;
append_text = false