diff --git a/Makefile.toml b/Makefile.toml index 48ef7dfd7969..7087ed1769cc 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -7,6 +7,9 @@ LIB_OUT_DIR = "debug" TARGET_OS = "unknown" DEV = true RELEASE = false +# FIXME currently needed to fix building for ios +# see https://github.com/matrix-org/matrix-rust-sdk/issues/4416 +CARGO_FEATURE_NO_NEON=1 [env.release] RELEASE = true diff --git a/native/acter/src/api/uniffi_api.rs b/native/acter/src/api/uniffi_api.rs index c6a206da7a6e..27f1561e0795 100644 --- a/native/acter/src/api/uniffi_api.rs +++ b/native/acter/src/api/uniffi_api.rs @@ -41,34 +41,69 @@ impl NotificationItem { let ApiNotificationItem { title, - push_style, - target_url, - room_invite, thread_id, - body, noisy, sender, - image, + inner, .. } = value; + let target_url = inner.target_url(); + let room_invite = inner.room_invite(); + let push_style = inner.key(); + let body = inner.body(); + + let mut msg_title = title; let mut short_msg = None; - if let Some(invite) = room_invite { - short_msg = Some(invite); - } else if let Some(content) = body { - short_msg = Some(content.body()); + let parent_title = if let Some(p) = inner.parent() { + let parent_title = p.title().unwrap_or("boost".to_owned()); + let parent_emoji = p.emoji(); + Some(format!("{parent_emoji} {parent_title}")) + } else { + None + }; + + let sender_name = sender + .display_name() + .clone() + .unwrap_or_else(|| sender.user_id()); + + if let Some(content) = body { + let msg = Some(content.body()); + short_msg = Some(format!("${sender_name}: $msg")) } - if push_style == "chat" { - if let Some(sender_name) = sender.display_name() { - // wrap the user display name before the message - short_msg = Some(format!("${sender_name}: $short_msg")); + match push_style.as_str() { + "invite" => { + if let Some(invite_id) = room_invite { + short_msg = Some(invite_id.to_string()); + } + } + "comment" => { + if let Some(pt) = parent_title { + msg_title = format!("💬 Comment on {pt}"); + } else { + msg_title = "💬 Comment".to_owned(); + } + } + "reaction" => { + short_msg = Some(sender_name); + let reaction = inner.reaction_key().unwrap_or("❤️".to_owned()); + + if let Some(pt) = parent_title { + msg_title = format!("{reaction} to {pt}"); + } else { + msg_title = reaction; + } + } + _ => { + // e.g. "chat" -> default is fine. } } NotificationItem { - title, + title: msg_title, body: short_msg, push_style, target_url,