2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Added api support for clicks on sponsored messages with media.

This commit is contained in:
23rd
2024-09-17 17:41:52 +03:00
committed by John Preston
parent a2fad84dae
commit 3f6d184435
8 changed files with 64 additions and 28 deletions

View File

@@ -3715,14 +3715,16 @@ void OverlayWidget::initSponsoredButton() {
} else if (!has && !_sponsoredButton) {
return;
}
const auto &component = _session->sponsoredMessages();
const auto details = component.lookupDetails(_message->fullId());
const auto sponsoredMessages = &_session->sponsoredMessages();
const auto fullId = _message->fullId();
const auto details = sponsoredMessages->lookupDetails(fullId);
_sponsoredButton = base::make_unique_q<SponsoredButton>(_body);
_sponsoredButton->setText(details.buttonText);
_sponsoredButton->setOpacity(1.0);
_sponsoredButton->setClickedCallback([=, link = details.link] {
UrlClickHandler::Open(link);
sponsoredMessages->clicked(fullId, false, true);
hide();
});
}
@@ -6020,7 +6022,18 @@ void OverlayWidget::handleMouseRelease(
if (_stories) {
_stories->contentPressed(false);
} else if (_streamed && !_window->mousePressCancelled()) {
playbackPauseResume();
if (_sponsoredButton && _session && _message) {
const auto sponsoredMessages = &_session->sponsoredMessages();
const auto fullId = _message->fullId();
const auto details = sponsoredMessages->lookupDetails(fullId);
if (const auto link = details.link; !link.isEmpty()) {
UrlClickHandler::Open(link);
sponsoredMessages->clicked(fullId, true, true);
hide();
}
} else {
playbackPauseResume();
}
}
} else if (_pressed) {
if (_dragging) {