Skip to content

Commit

Permalink
Added ability to hide every sponsored message to premium users.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd authored and john-preston committed May 28, 2024
1 parent f6b849e commit 3b68703
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Telegram/SourceFiles/history/history_inner_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ void FillSponsoredMessagesMenu(
menu->addSeparator(&st::expandedMenuSeparator);
}
menu->addAction(tr::lng_sponsored_hide_ads(tr::now), [=] {
ShowPremiumPreviewBox(controller, PremiumFeature::NoAds);
if (controller->session().premium()) {
using Result = Data::SponsoredReportResult;
controller->session().sponsoredMessages().createReportCallback(
itemId)(Result::Id("-1"), [](const auto &) {});
} else {
ShowPremiumPreviewBox(controller, PremiumFeature::NoAds);
}
}, &st::menuIconCancel);
}

Expand Down
10 changes: 9 additions & 1 deletion Telegram/SourceFiles/history/history_item_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ For license and copyright information please follow this link:
#include "api/api_text_entities.h"
#include "boxes/premium_preview_box.h"
#include "calls/calls_instance.h"
#include "data/components/sponsored_messages.h"
#include "data/stickers/data_custom_emoji.h"
#include "data/notify/data_notify_settings.h"
#include "data/data_channel.h"
Expand Down Expand Up @@ -363,7 +364,14 @@ ClickHandlerPtr HideSponsoredClickHandler() {
return std::make_shared<LambdaClickHandler>([=](ClickContext context) {
const auto my = context.other.value<ClickHandlerContext>();
if (const auto controller = my.sessionWindow.get()) {
ShowPremiumPreviewBox(controller, PremiumFeature::NoAds);
const auto &session = controller->session();
if (session.premium()) {
using Result = Data::SponsoredReportResult;
session.sponsoredMessages().createReportCallback(
my.itemId)(Result::Id("-1"), [](const auto &) {});
} else {
ShowPremiumPreviewBox(controller, PremiumFeature::NoAds);
}
}
});
}
Expand Down

0 comments on commit 3b68703

Please sign in to comment.