Added tooltip and ability to copy external link to sponsored messages.
This commit is contained in:
parent
456f4d7b8a
commit
3332f012cf
|
@ -297,7 +297,7 @@ void SponsoredMessages::append(
|
||||||
: ImageWithLocation{};
|
: ImageWithLocation{};
|
||||||
return SponsoredFrom{
|
return SponsoredFrom{
|
||||||
.title = qs(data.vsite_name()),
|
.title = qs(data.vsite_name()),
|
||||||
.isExternalLink = true,
|
.externalLink = externalLink,
|
||||||
.userpic = std::move(userpic),
|
.userpic = std::move(userpic),
|
||||||
.isForceUserpicDisplay = message.data().is_show_peer_photo(),
|
.isForceUserpicDisplay = message.data().is_show_peer_photo(),
|
||||||
};
|
};
|
||||||
|
|
|
@ -31,7 +31,7 @@ struct SponsoredFrom {
|
||||||
bool isBot = false;
|
bool isBot = false;
|
||||||
bool isExactPost = false;
|
bool isExactPost = false;
|
||||||
bool isRecommended = false;
|
bool isRecommended = false;
|
||||||
bool isExternalLink = false;
|
QString externalLink;
|
||||||
ImageWithLocation userpic;
|
ImageWithLocation userpic;
|
||||||
bool isForceUserpicDisplay = false;
|
bool isForceUserpicDisplay = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -2544,7 +2544,9 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
|
||||||
}, &st::menuIconLink);
|
}, &st::menuIconLink);
|
||||||
}
|
}
|
||||||
if (item && item->isSponsored()) {
|
if (item && item->isSponsored()) {
|
||||||
_menu->addSeparator(&st::expandedMenuSeparator);
|
if (!_menu->empty()) {
|
||||||
|
_menu->addSeparator(&st::expandedMenuSeparator);
|
||||||
|
}
|
||||||
auto item = base::make_unique_q<Ui::Menu::MultilineAction>(
|
auto item = base::make_unique_q<Ui::Menu::MultilineAction>(
|
||||||
_menu,
|
_menu,
|
||||||
st::menuWithIcons,
|
st::menuWithIcons,
|
||||||
|
|
|
@ -3234,8 +3234,9 @@ void HistoryItem::setSponsoredFrom(const Data::SponsoredFrom &from) {
|
||||||
from.userpic);
|
from.userpic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sponsored->externalLink = from.externalLink;
|
||||||
using Type = HistoryMessageSponsored::Type;
|
using Type = HistoryMessageSponsored::Type;
|
||||||
sponsored->type = from.isExternalLink
|
sponsored->type = (!from.externalLink.isEmpty())
|
||||||
? Type::ExternalLink
|
? Type::ExternalLink
|
||||||
: from.isExactPost
|
: from.isExactPost
|
||||||
? Type::Post
|
? Type::Post
|
||||||
|
|
|
@ -146,6 +146,7 @@ struct HistoryMessageSponsored : public RuntimeComponent<HistoryMessageSponsored
|
||||||
Type type = Type::User;
|
Type type = Type::User;
|
||||||
bool recommended = false;
|
bool recommended = false;
|
||||||
bool isForceUserpicDisplay = false;
|
bool isForceUserpicDisplay = false;
|
||||||
|
QString externalLink;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReplyToMessagePointer final {
|
class ReplyToMessagePointer final {
|
||||||
|
|
|
@ -103,6 +103,36 @@ inline auto WebPageToPhrase(not_null<WebPageData*> webpage) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] ClickHandlerPtr SponsoredLink(
|
||||||
|
not_null<HistoryMessageSponsored*> sponsored) {
|
||||||
|
if (!sponsored->externalLink.isEmpty()) {
|
||||||
|
return std::make_shared<UrlClickHandler>(
|
||||||
|
sponsored->externalLink,
|
||||||
|
false);
|
||||||
|
} else {
|
||||||
|
return std::make_shared<LambdaClickHandler>([](ClickContext context) {
|
||||||
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
const auto controller = my.sessionWindow.get();
|
||||||
|
if (!controller) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto &data = controller->session().data();
|
||||||
|
const auto details = data.sponsoredMessages().lookupDetails(
|
||||||
|
my.itemId);
|
||||||
|
if (!details.externalLink.isEmpty()) {
|
||||||
|
File::OpenUrl(details.externalLink);
|
||||||
|
} else if (details.hash) {
|
||||||
|
Api::CheckChatInvite(controller, *details.hash);
|
||||||
|
} else if (details.peer) {
|
||||||
|
controller->showPeerHistory(
|
||||||
|
details.peer,
|
||||||
|
Window::SectionShow::Way::Forward,
|
||||||
|
details.msgId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
struct ViewButton::Inner {
|
struct ViewButton::Inner {
|
||||||
|
@ -156,24 +186,7 @@ ViewButton::Inner::Inner(
|
||||||
not_null<HistoryMessageSponsored*> sponsored,
|
not_null<HistoryMessageSponsored*> sponsored,
|
||||||
Fn<void()> updateCallback)
|
Fn<void()> updateCallback)
|
||||||
: margins(st::historyViewButtonMargins)
|
: margins(st::historyViewButtonMargins)
|
||||||
, link(std::make_shared<LambdaClickHandler>([=](ClickContext context) {
|
, link(SponsoredLink(sponsored))
|
||||||
const auto my = context.other.value<ClickHandlerContext>();
|
|
||||||
if (const auto controller = my.sessionWindow.get()) {
|
|
||||||
const auto &data = controller->session().data();
|
|
||||||
const auto itemId = my.itemId;
|
|
||||||
const auto details = data.sponsoredMessages().lookupDetails(itemId);
|
|
||||||
if (!details.externalLink.isEmpty()) {
|
|
||||||
File::OpenUrl(details.externalLink);
|
|
||||||
} else if (details.hash) {
|
|
||||||
Api::CheckChatInvite(controller, *details.hash);
|
|
||||||
} else if (details.peer) {
|
|
||||||
controller->showPeerHistory(
|
|
||||||
details.peer,
|
|
||||||
Window::SectionShow::Way::Forward,
|
|
||||||
details.msgId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
, updateCallback(std::move(updateCallback))
|
, updateCallback(std::move(updateCallback))
|
||||||
, externalLink(sponsored->type == SponsoredType::ExternalLink)
|
, externalLink(sponsored->type == SponsoredType::ExternalLink)
|
||||||
, text(st::historyViewButtonTextStyle, SponsoredPhrase(sponsored->type)) {
|
, text(st::historyViewButtonTextStyle, SponsoredPhrase(sponsored->type)) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit e24eaa6b32799119caa78caacd57216f81d3e1a7
|
Subproject commit aaa88be9d7eaba529b31d742444e80846a2aa003
|
Loading…
Reference in New Issue
Block a user