Skip to content

Commit 9bdc19e

Browse files
ilya-fedinjohn-preston
authored andcommitted
Format markup-lacking Linux notifications using lng_dialogs_text_with_from
1 parent 25cd610 commit 9bdc19e

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -537,17 +537,23 @@ void Manager::Private::showNotification(
537537
.msgId = info.itemId,
538538
};
539539
auto notification = _application
540-
? Gio::Notification::new_(
541-
info.subtitle.isEmpty()
542-
? info.title.toStdString()
543-
: info.subtitle.toStdString()
544-
+ " (" + info.title.toStdString() + ')')
540+
? Gio::Notification::new_(info.title.toStdString())
545541
: Gio::Notification();
546542

547543
std::vector<gi::cstring> actions;
548544
auto hints = GLib::VariantDict::new_();
549545
if (notification) {
550-
notification.set_body(info.message.toStdString());
546+
notification.set_body(info.subtitle.isEmpty()
547+
? info.message.toStdString()
548+
: tr::lng_dialogs_text_with_from(
549+
tr::now,
550+
lt_from_part,
551+
tr::lng_dialogs_text_from_wrapped(
552+
tr::now,
553+
lt_from,
554+
info.subtitle),
555+
lt_message,
556+
info.message).toStdString());
551557

552558
notification.set_icon(
553559
Gio::ThemedIcon::new_(ApplicationIconName().toStdString()));
@@ -726,8 +732,6 @@ void Manager::Private::showNotification(
726732
const auto hasImage = !imageKey.empty()
727733
&& hints.lookup_value(imageKey);
728734

729-
const auto hasBodyMarkup = HasCapability("body-markup");
730-
731735
const auto callbackWrap = gi::unwrap(
732736
Gio::AsyncReadyCallback(
733737
crl::guard(this, [=](
@@ -766,17 +770,24 @@ void Manager::Private::showNotification(
766770
(!hasImage
767771
? ApplicationIconName().toStdString()
768772
: std::string()).c_str(),
769-
(hasBodyMarkup || info.subtitle.isEmpty()
770-
? info.title.toStdString()
771-
: info.subtitle.toStdString()
772-
+ " (" + info.title.toStdString() + ')').c_str(),
773-
(hasBodyMarkup
773+
info.title.toStdString().c_str(),
774+
(HasCapability("body-markup")
774775
? info.subtitle.isEmpty()
775776
? info.message.toHtmlEscaped().toStdString()
776777
: u"<b>%1</b>\n%2"_q.arg(
777778
info.subtitle.toHtmlEscaped(),
778779
info.message.toHtmlEscaped()).toStdString()
779-
: info.message.toStdString()).c_str(),
780+
: info.subtitle.isEmpty()
781+
? info.message.toStdString()
782+
: tr::lng_dialogs_text_with_from(
783+
tr::now,
784+
lt_from_part,
785+
tr::lng_dialogs_text_from_wrapped(
786+
tr::now,
787+
lt_from,
788+
info.subtitle),
789+
lt_message,
790+
info.message).toStdString()).c_str(),
780791
!actions.empty()
781792
? (actions
782793
| ranges::views::transform(&gi::cstring::c_str)

0 commit comments

Comments
 (0)