From 735bbef655ea6945d31604600b0fdebc931dfbc5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 1 Jul 2025 12:23:55 +0400 Subject: [PATCH] Fix phone/card click handler generation. --- Telegram/SourceFiles/core/ui_integration.cpp | 4 ++-- .../SourceFiles/history/view/history_view_element.cpp | 8 +++++++- Telegram/SourceFiles/history/view/history_view_element.h | 1 + .../history/view/media/history_view_todo_list.cpp | 1 + 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/core/ui_integration.cpp b/Telegram/SourceFiles/core/ui_integration.cpp index 3283ea2b35..c918904384 100644 --- a/Telegram/SourceFiles/core/ui_integration.cpp +++ b/Telegram/SourceFiles/core/ui_integration.cpp @@ -254,11 +254,11 @@ std::shared_ptr UiIntegration::createLinkHandler( case EntityType::Pre: return std::make_shared(data.text, data.type); case EntityType::Phone: - return my->session + return (my && my->session) ? std::make_shared(my->session, data.text) : nullptr; case EntityType::BankCard: - return my->session + return (my && my->session) ? std::make_shared(my->session, data.text) : nullptr; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index aa3f0950b8..3c1c1aeff9 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -601,6 +601,7 @@ void MonoforumSenderBar::Paint( } void ServicePreMessage::init( + not_null view, PreparedServiceText string, ClickHandlerPtr fullClickHandler, std::unique_ptr media) { @@ -608,7 +609,11 @@ void ServicePreMessage::init( st::serviceTextStyle, string.text, kMarkupTextOptions, - st::msgMinWidth); + st::msgMinWidth, + Core::TextContext({ + .session = &view->history()->session(), + .repaint = [=] { view->customEmojiRepaint(); }, + })); handler = std::move(fullClickHandler); for (auto i = 0; i != int(string.links.size()); ++i) { text.setLink(i + 1, string.links[i]); @@ -1675,6 +1680,7 @@ void Element::setServicePreMessage( AddComponents(ServicePreMessage::Bit()); const auto service = Get(); service->init( + this, std::move(text), std::move(fullClickHandler), std::move(media)); diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 1bf9a8e1a0..6f7a4edea0 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -310,6 +310,7 @@ private: // displaying some text in layout of a service message above the message. struct ServicePreMessage : RuntimeComponent { void init( + not_null view, PreparedServiceText string, ClickHandlerPtr fullClickHandler, std::unique_ptr media = nullptr); diff --git a/Telegram/SourceFiles/history/view/media/history_view_todo_list.cpp b/Telegram/SourceFiles/history/view/media/history_view_todo_list.cpp index e9d4abc6b4..8249613074 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_todo_list.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_todo_list.cpp @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "history/history.h" #include "history/history_item.h" +#include "history/history_item_components.h" #include "history/view/history_view_message.h" #include "history/view/history_view_cursor_state.h" #include "calls/calls_instance.h"