mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-17 22:57:11 +02:00
Added ability to open media from sponsored messages.
This commit is contained in:
parent
624e068f2f
commit
e4538947c3
2 changed files with 27 additions and 7 deletions
|
@ -1254,6 +1254,11 @@ TextState WebPage::textState(QPoint point, StateRequest request) const {
|
|||
auto tshift = inner.top();
|
||||
auto paintw = inner.width();
|
||||
|
||||
const auto hasSponsoredMedia = sponsored && sponsored->hasMedia;
|
||||
if (hasSponsoredMedia && _attach) {
|
||||
tshift += _attach->height() + st::mediaInBubbleSkip;
|
||||
}
|
||||
|
||||
const auto lineHeight = UnitedLineHeight();
|
||||
auto inThumb = false;
|
||||
if (asArticle()) {
|
||||
|
@ -1335,13 +1340,14 @@ TextState WebPage::textState(QPoint point, StateRequest request) const {
|
|||
if (inThumb) {
|
||||
result.link = _openl;
|
||||
} else if (_attach) {
|
||||
const auto attachAtTop = (!_siteNameLines
|
||||
&& !_titleLines
|
||||
&& !_descriptionLines)
|
||||
|| (sponsored && sponsored->hasMedia);
|
||||
const auto attachAtTop = hasSponsoredMedia
|
||||
|| (!_siteNameLines && !_titleLines && !_descriptionLines);
|
||||
if (!attachAtTop) {
|
||||
tshift += st::mediaInBubbleSkip;
|
||||
}
|
||||
if (hasSponsoredMedia) {
|
||||
tshift -= _attach->height();
|
||||
}
|
||||
|
||||
const auto rect = QRect(
|
||||
inner.left(),
|
||||
|
@ -1352,18 +1358,25 @@ TextState WebPage::textState(QPoint point, StateRequest request) const {
|
|||
const auto attachLeft = rtl()
|
||||
? width() - (inner.left() - bubble.left()) - _attach->width()
|
||||
: (inner.left() - bubble.left());
|
||||
const auto attachTop = tshift - bubble.top();
|
||||
const auto attachTop = hasSponsoredMedia
|
||||
? inner.top()
|
||||
: (tshift - bubble.top());
|
||||
result = _attach->textState(
|
||||
point - QPoint(attachLeft, attachTop),
|
||||
request);
|
||||
if (result.cursor == CursorState::Enlarge) {
|
||||
if (hasSponsoredMedia) {
|
||||
} else if (result.cursor == CursorState::Enlarge) {
|
||||
result.cursor = CursorState::None;
|
||||
} else {
|
||||
result.link = replaceAttachLink(result.link);
|
||||
}
|
||||
}
|
||||
if (hasSponsoredMedia) {
|
||||
tshift += _attach->height();
|
||||
}
|
||||
}
|
||||
if ((!result.link || sponsored) && outer.contains(point)) {
|
||||
if ((!result.link || (sponsored && !hasSponsoredMedia))
|
||||
&& outer.contains(point)) {
|
||||
result.link = _openl;
|
||||
}
|
||||
if (const auto hint = hintData()) {
|
||||
|
|
|
@ -52,6 +52,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "history/history_item_helpers.h"
|
||||
#include "history/view/media/history_view_media.h"
|
||||
#include "history/view/reactions/history_view_reactions_selector.h"
|
||||
#include "data/components/sponsored_messages.h"
|
||||
#include "data/data_session.h"
|
||||
#include "data/data_changes.h"
|
||||
#include "data/data_channel.h"
|
||||
|
@ -3101,6 +3102,12 @@ void OverlayWidget::refreshCaption() {
|
|||
} else if (_message) {
|
||||
if (const auto media = _message->media()) {
|
||||
if (media->webpage()) {
|
||||
if (_message->isSponsored()) {
|
||||
return TextWithEntities()
|
||||
.append(Ui::Text::Bold(media->webpage()->title))
|
||||
.append('\n')
|
||||
.append(media->webpage()->description);
|
||||
}
|
||||
return TextWithEntities();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue