From 1b604bed0b1ea28eba3c5c8371fef6461999c3e2 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 9 Jun 2022 11:00:29 +0400 Subject: [PATCH] Fix bottom shadow in premium settings. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/history/history_inner_widget.cpp | 5 +++++ Telegram/SourceFiles/info/info_content_widget.cpp | 4 ++++ Telegram/SourceFiles/info/info_content_widget.h | 1 + Telegram/SourceFiles/info/info_wrap_widget.cpp | 5 +++++ 5 files changed, 16 insertions(+) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index da75bcc49..19e7031c2 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3311,6 +3311,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_view_button_voice_chat_channel" = "Live stream"; "lng_view_button_request_join" = "Request to Join"; +"lng_sponsored_hide_ads" = "Hide"; "lng_sponsored_title" = "What are sponsored messages?"; "lng_sponsored_info_description1" = "Unlike other apps, Telegram never uses your private data to target ads. Sponsored messages on Telegram are based solely on the topic of the public channels in which they are shown. This means that no user data is mined or analyzed to display ads, and every user viewing a channel on Telegram sees the same sponsored messages.\n\nUnlike other apps, Telegram doesn't track whether you tapped on a sponsored message and doesn't profile you based on your activity. We also prevent external links in sponsored messages to ensure that third parties can’t spy on our users. We believe that everyone has the right to privacy, and technological platforms should respect that.\n\nTelegram offers a free and unlimited service to hundreds of millions of users, which involves significant server and traffic costs. In order to remain independent and stay true to its values, Telegram developed a paid tool to promote messages with user privacy in mind. We welcome responsible advertisers at:"; "lng_sponsored_info_description2" = "Sponsored Messages are currently in test mode. Once they are fully launched and allow Telegram to cover its basic costs, we will start sharing ad revenue with the owners of public channels in which sponsored messages are displayed.\n\nOnline ads should no longer be synonymous with abuse of user privacy. Let us redefine how a tech company should operate – together."; diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index 594ef07d8..a1d62cccf 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -85,6 +85,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/stickers/data_stickers.h" #include "data/data_sponsored_messages.h" #include "dialogs/ui/dialogs_video_userpic.h" +#include "settings/settings_premium.h" #include "facades.h" #include "styles/style_chat.h" #include "styles/style_window.h" // st::windowMinWidth @@ -2324,6 +2325,10 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) { _menu->addAction(tr::lng_sponsored_title({}), [=] { _controller->show(Box(Ui::AboutSponsoredBox)); }, &st::menuIconInfo); + _menu->addSeparator(); + _menu->addAction(tr::lng_sponsored_hide_ads({}), [=] { + Settings::ShowPremium(_controller, "no_ads"); + }, &st::menuIconBlock); } if (!item->isService() && view diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index cde6fe95c..0a40110e6 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -307,6 +307,10 @@ int ContentWidget::scrollBottomSkip() const { return _scrollBottomSkip.current(); } +rpl::producer ContentWidget::scrollBottomSkipValue() const { + return _scrollBottomSkip.value(); +} + rpl::producer ContentWidget::desiredBottomShadowVisibility() const { using namespace rpl::mappers; return rpl::combine( diff --git a/Telegram/SourceFiles/info/info_content_widget.h b/Telegram/SourceFiles/info/info_content_widget.h index eae8e5431..a64c6ec26 100644 --- a/Telegram/SourceFiles/info/info_content_widget.h +++ b/Telegram/SourceFiles/info/info_content_widget.h @@ -86,6 +86,7 @@ public: virtual void saveChanges(FnMut done); [[nodiscard]] int scrollBottomSkip() const; + [[nodiscard]] rpl::producer scrollBottomSkipValue() const; [[nodiscard]] rpl::producer desiredBottomShadowVisibility() const; protected: diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index e0daabd2e..e96dbdf5c 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -687,6 +687,11 @@ void WrapWidget::finishShowContent() { _bottomShadow->finishAnimating(); _contentChanges.fire({}); + _content->scrollBottomSkipValue( + ) | rpl::start_with_next([=] { + updateContentGeometry(); + }, _content->lifetime()); + // This was done for tabs support. // //if (_topTabs) {