From 9bdc19e2fd4d497c8f403891848383a88faadc25 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 11 Apr 2025 14:01:09 +0000 Subject: [PATCH] Format markup-lacking Linux notifications using lng_dialogs_text_with_from --- .../linux/notifications_manager_linux.cpp | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index c100e00e06..45cb6a3875 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -537,17 +537,23 @@ void Manager::Private::showNotification( .msgId = info.itemId, }; auto notification = _application - ? Gio::Notification::new_( - info.subtitle.isEmpty() - ? info.title.toStdString() - : info.subtitle.toStdString() - + " (" + info.title.toStdString() + ')') + ? Gio::Notification::new_(info.title.toStdString()) : Gio::Notification(); std::vector actions; auto hints = GLib::VariantDict::new_(); if (notification) { - notification.set_body(info.message.toStdString()); + notification.set_body(info.subtitle.isEmpty() + ? info.message.toStdString() + : tr::lng_dialogs_text_with_from( + tr::now, + lt_from_part, + tr::lng_dialogs_text_from_wrapped( + tr::now, + lt_from, + info.subtitle), + lt_message, + info.message).toStdString()); notification.set_icon( Gio::ThemedIcon::new_(ApplicationIconName().toStdString())); @@ -726,8 +732,6 @@ void Manager::Private::showNotification( const auto hasImage = !imageKey.empty() && hints.lookup_value(imageKey); - const auto hasBodyMarkup = HasCapability("body-markup"); - const auto callbackWrap = gi::unwrap( Gio::AsyncReadyCallback( crl::guard(this, [=]( @@ -766,17 +770,24 @@ void Manager::Private::showNotification( (!hasImage ? ApplicationIconName().toStdString() : std::string()).c_str(), - (hasBodyMarkup || info.subtitle.isEmpty() - ? info.title.toStdString() - : info.subtitle.toStdString() - + " (" + info.title.toStdString() + ')').c_str(), - (hasBodyMarkup + info.title.toStdString().c_str(), + (HasCapability("body-markup") ? info.subtitle.isEmpty() ? info.message.toHtmlEscaped().toStdString() : u"%1\n%2"_q.arg( info.subtitle.toHtmlEscaped(), info.message.toHtmlEscaped()).toStdString() - : info.message.toStdString()).c_str(), + : info.subtitle.isEmpty() + ? info.message.toStdString() + : tr::lng_dialogs_text_with_from( + tr::now, + lt_from_part, + tr::lng_dialogs_text_from_wrapped( + tr::now, + lt_from, + info.subtitle), + lt_message, + info.message).toStdString()).c_str(), !actions.empty() ? (actions | ranges::views::transform(&gi::cstring::c_str)