From 3569615b216166d8ac2f150317041ddac2d58b3e Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 26 Feb 2025 18:13:46 +0000 Subject: [PATCH] Use gi::cstring for notification actions --- .../linux/notifications_manager_linux.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp index d67fbc68d..ff3535969 100644 --- a/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp +++ b/Telegram/SourceFiles/platform/linux/notifications_manager_linux.cpp @@ -174,7 +174,7 @@ private: XdgNotifications::Notifications _interface; std::string _title; std::string _body; - std::vector _actions; + std::vector _actions; GLib::VariantDict _hints; std::string _imageKey; @@ -362,6 +362,8 @@ bool NotificationData::init(const Info &info) { _lifetime.add([=] { _interface.disconnect(activationTokenSignalId); }); + + _actions.push_back({}); } if (HasCapability("action-icons")) { @@ -441,11 +443,6 @@ void NotificationData::show() { // a hack for snap's activation restriction const auto weak = base::make_weak(this); StartServiceAsync(_proxy.get_connection(), crl::guard(weak, [=] { - auto actions = _actions - | ranges::views::transform(&std::string::c_str) - | ranges::to_vector; - actions.push_back(nullptr); - const auto callbackWrap = gi::unwrap( Gio::AsyncReadyCallback( crl::guard(weak, [=](GObject::Object, Gio::AsyncResult res) { @@ -476,7 +473,11 @@ void NotificationData::show() { : std::string()).c_str(), _title.c_str(), _body.c_str(), - actions.data(), + !_actions.empty() + ? (_actions + | ranges::views::transform(&gi::cstring::c_str) + | ranges::to_vector).data() + : nullptr, _hints.end().gobj_(), -1, nullptr,