mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to open menu for sponsored messages without history item.
This commit is contained in:
parent
304bcfd343
commit
2db30690ce
4 changed files with 13 additions and 18 deletions
|
@ -409,7 +409,7 @@ ClickHandlerPtr ReportSponsoredClickHandler(not_null<HistoryItem*> item) {
|
||||||
Menu::ShowSponsored(
|
Menu::ShowSponsored(
|
||||||
controller->widget(),
|
controller->widget(),
|
||||||
controller->uiShow(),
|
controller->uiShow(),
|
||||||
item);
|
item->fullId());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1574,7 +1574,8 @@ void OverlayWidget::fillContextMenuActions(
|
||||||
if (_message && _message->isSponsored()) {
|
if (_message && _message->isSponsored()) {
|
||||||
if (const auto window = findWindow()) {
|
if (const auto window = findWindow()) {
|
||||||
const auto show = window->uiShow();
|
const auto show = window->uiShow();
|
||||||
Menu::FillSponsored(_body, addAction, show, _message, true);
|
const auto fullId = _message->fullId();
|
||||||
|
Menu::FillSponsored(_body, addAction, show, fullId, true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,10 +218,8 @@ void AboutBox(
|
||||||
|
|
||||||
void ShowReportSponsoredBox(
|
void ShowReportSponsoredBox(
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
not_null<HistoryItem*> item) {
|
const FullMsgId &fullId) {
|
||||||
const auto peer = item->history()->peer;
|
auto &sponsoredMessages = show->session().sponsoredMessages();
|
||||||
auto &sponsoredMessages = peer->session().sponsoredMessages();
|
|
||||||
const auto fullId = item->fullId();
|
|
||||||
const auto report = sponsoredMessages.createReportCallback(fullId);
|
const auto report = sponsoredMessages.createReportCallback(fullId);
|
||||||
const auto guideLink = Ui::Text::Link(
|
const auto guideLink = Ui::Text::Link(
|
||||||
tr::lng_report_sponsored_reported_link(tr::now),
|
tr::lng_report_sponsored_reported_link(tr::now),
|
||||||
|
@ -306,18 +304,16 @@ void FillSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const Ui::Menu::MenuCallback &addAction,
|
const Ui::Menu::MenuCallback &addAction,
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
not_null<HistoryItem*> item,
|
const FullMsgId &fullId,
|
||||||
bool mediaViewer) {
|
bool mediaViewer) {
|
||||||
Expects(item->isSponsored());
|
const auto session = &show->session();
|
||||||
|
|
||||||
const auto session = &item->history()->session();
|
|
||||||
|
|
||||||
addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
addAction(tr::lng_sponsored_menu_revenued_about(tr::now), [=] {
|
||||||
show->show(Box(AboutBox, show));
|
show->show(Box(AboutBox, show));
|
||||||
}, (mediaViewer ? &st::mediaMenuIconInfo : &st::menuIconInfo));
|
}, (mediaViewer ? &st::mediaMenuIconInfo : &st::menuIconInfo));
|
||||||
|
|
||||||
addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] {
|
addAction(tr::lng_sponsored_menu_revenued_report(tr::now), [=] {
|
||||||
ShowReportSponsoredBox(show, item);
|
ShowReportSponsoredBox(show, fullId);
|
||||||
}, (mediaViewer ? &st::mediaMenuIconBlock : &st::menuIconBlock));
|
}, (mediaViewer ? &st::mediaMenuIconBlock : &st::menuIconBlock));
|
||||||
|
|
||||||
addAction({
|
addAction({
|
||||||
|
@ -331,7 +327,7 @@ void FillSponsored(
|
||||||
if (session->premium()) {
|
if (session->premium()) {
|
||||||
using Result = Data::SponsoredReportResult;
|
using Result = Data::SponsoredReportResult;
|
||||||
session->sponsoredMessages().createReportCallback(
|
session->sponsoredMessages().createReportCallback(
|
||||||
item->fullId())(Result::Id("-1"), [](const auto &) {});
|
fullId)(Result::Id("-1"), [](const auto &) {});
|
||||||
} else {
|
} else {
|
||||||
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
||||||
}
|
}
|
||||||
|
@ -341,9 +337,7 @@ void FillSponsored(
|
||||||
void ShowSponsored(
|
void ShowSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
not_null<HistoryItem*> item) {
|
const FullMsgId &fullId) {
|
||||||
Expects(item->isSponsored());
|
|
||||||
|
|
||||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
||||||
parent.get(),
|
parent.get(),
|
||||||
st::popupMenuWithIcons);
|
st::popupMenuWithIcons);
|
||||||
|
@ -352,7 +346,7 @@ void ShowSponsored(
|
||||||
parent,
|
parent,
|
||||||
Ui::Menu::CreateAddActionCallback(menu),
|
Ui::Menu::CreateAddActionCallback(menu),
|
||||||
show,
|
show,
|
||||||
item,
|
fullId,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
menu->popup(QCursor::pos());
|
menu->popup(QCursor::pos());
|
||||||
|
|
|
@ -26,13 +26,13 @@ void FillSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
const Ui::Menu::MenuCallback &addAction,
|
const Ui::Menu::MenuCallback &addAction,
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
not_null<HistoryItem*> item,
|
const FullMsgId &fullId,
|
||||||
bool mediaViewer);
|
bool mediaViewer);
|
||||||
|
|
||||||
void ShowSponsored(
|
void ShowSponsored(
|
||||||
not_null<Ui::RpWidget*> parent,
|
not_null<Ui::RpWidget*> parent,
|
||||||
std::shared_ptr<ChatHelpers::Show> show,
|
std::shared_ptr<ChatHelpers::Show> show,
|
||||||
not_null<HistoryItem*> item);
|
const FullMsgId &fullId);
|
||||||
|
|
||||||
void ShowSponsoredAbout(std::shared_ptr<ChatHelpers::Show> show);
|
void ShowSponsoredAbout(std::shared_ptr<ChatHelpers::Show> show);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue