mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Added ability to hide single sponsored message to premium users.
This commit is contained in:
parent
7a95b38d3c
commit
bc11c66777
2 changed files with 25 additions and 12 deletions
|
@ -443,6 +443,22 @@ auto SponsoredMessages::createReportCallback(const FullMsgId &fullId)
|
|||
return;
|
||||
}
|
||||
|
||||
const auto erase = [=] {
|
||||
const auto it = _data.find(history);
|
||||
if (it != end(_data)) {
|
||||
auto &list = it->second.entries;
|
||||
const auto proj = [&](const Entry &e) {
|
||||
return e.itemFullId == fullId;
|
||||
};
|
||||
list.erase(ranges::remove_if(list, proj), end(list));
|
||||
}
|
||||
};
|
||||
|
||||
if (optionId == Result::Id("-1")) {
|
||||
erase();
|
||||
return;
|
||||
}
|
||||
|
||||
state->requestId = _session->api().request(
|
||||
MTPchannels_ReportSponsoredMessage(
|
||||
channel->inputChannel,
|
||||
|
@ -469,14 +485,7 @@ auto SponsoredMessages::createReportCallback(const FullMsgId &fullId)
|
|||
}, [](const TLAdsHidden &data) -> Result {
|
||||
return { .result = Result::FinalStep::Hidden };
|
||||
}, [&](const TLReported &data) -> Result {
|
||||
const auto it = _data.find(history);
|
||||
if (it != end(_data)) {
|
||||
auto &list = it->second.entries;
|
||||
const auto proj = [&](const Entry &e) {
|
||||
return e.itemFullId == fullId;
|
||||
};
|
||||
list.erase(ranges::remove_if(list, proj), end(list));
|
||||
}
|
||||
erase();
|
||||
if (optionId == Result::Id("1")) { // I don't like it.
|
||||
return { .result = Result::FinalStep::Silence };
|
||||
}
|
||||
|
|
|
@ -332,9 +332,7 @@ void ShowSponsored(
|
|||
not_null<HistoryItem*> item) {
|
||||
Expects(item->isSponsored());
|
||||
|
||||
struct State final {
|
||||
};
|
||||
const auto state = std::make_shared<State>();
|
||||
const auto session = &item->history()->session();
|
||||
|
||||
const auto menu = Ui::CreateChild<Ui::PopupMenu>(
|
||||
parent.get(),
|
||||
|
@ -351,7 +349,13 @@ void ShowSponsored(
|
|||
menu->addSeparator(&st::expandedMenuSeparator);
|
||||
|
||||
menu->addAction(tr::lng_sponsored_hide_ads(tr::now), [=] {
|
||||
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
||||
if (session->premium()) {
|
||||
using Result = Data::SponsoredReportResult;
|
||||
session->sponsoredMessages().createReportCallback(
|
||||
item->fullId())(Result::Id("-1"), [](const auto &) {});
|
||||
} else {
|
||||
ShowPremiumPreviewBox(show, PremiumFeature::NoAds);
|
||||
}
|
||||
}, &st::menuIconCancel);
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
|
|
Loading…
Add table
Reference in a new issue