Fix phone/card click handler generation.

This commit is contained in:
John Preston 2025-07-01 12:23:55 +04:00
parent 7006a07dd3
commit 735bbef655
4 changed files with 11 additions and 3 deletions

View file

@ -254,11 +254,11 @@ std::shared_ptr<ClickHandler> UiIntegration::createLinkHandler(
case EntityType::Pre:
return std::make_shared<MonospaceClickHandler>(data.text, data.type);
case EntityType::Phone:
return my->session
return (my && my->session)
? std::make_shared<PhoneClickHandler>(my->session, data.text)
: nullptr;
case EntityType::BankCard:
return my->session
return (my && my->session)
? std::make_shared<BankCardClickHandler>(my->session, data.text)
: nullptr;
}

View file

@ -601,6 +601,7 @@ void MonoforumSenderBar::Paint(
}
void ServicePreMessage::init(
not_null<Element*> view,
PreparedServiceText string,
ClickHandlerPtr fullClickHandler,
std::unique_ptr<Media> 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<ServicePreMessage>();
service->init(
this,
std::move(text),
std::move(fullClickHandler),
std::move(media));

View file

@ -310,6 +310,7 @@ private:
// displaying some text in layout of a service message above the message.
struct ServicePreMessage : RuntimeComponent<ServicePreMessage, Element> {
void init(
not_null<Element*> view,
PreparedServiceText string,
ClickHandlerPtr fullClickHandler,
std::unique_ptr<Media> media = nullptr);

View file

@ -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"