From e20770e256cc38cb6947c6f5999245f8c8af71ee Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 12 Mar 2024 18:17:43 +0400 Subject: [PATCH] Show IV button only if supported. --- Telegram/SourceFiles/data/data_web_page.cpp | 2 +- Telegram/SourceFiles/iv/iv_data.cpp | 19 +++++++++++++++++++ Telegram/SourceFiles/iv/iv_data.h | 5 +++++ Telegram/SourceFiles/ui/chat/chat.style | 2 +- Telegram/lib_webview | 2 +- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/data/data_web_page.cpp b/Telegram/SourceFiles/data/data_web_page.cpp index 3f30e746fa..297e997c57 100644 --- a/Telegram/SourceFiles/data/data_web_page.cpp +++ b/Telegram/SourceFiles/data/data_web_page.cpp @@ -172,7 +172,7 @@ WebPageType ParseWebPageType( } bool IgnoreIv(WebPageType type) { - return (type == WebPageType::Message); + return !Iv::ShowButton() || (type == WebPageType::Message); } WebPageType ParseWebPageType(const MTPDwebPage &page) { diff --git a/Telegram/SourceFiles/iv/iv_data.cpp b/Telegram/SourceFiles/iv/iv_data.cpp index 9313c2fba5..bbcca0b2cb 100644 --- a/Telegram/SourceFiles/iv/iv_data.cpp +++ b/Telegram/SourceFiles/iv/iv_data.cpp @@ -8,11 +8,17 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "iv/iv_data.h" #include "iv/iv_prepare.h" +#include "webview/webview_interface.h" #include #include namespace Iv { +namespace { + +bool FailureRecorded/* = false*/; + +} // namespace QByteArray GeoPointId(Geo point) { const auto lat = int(point.lat * 1000000); @@ -89,4 +95,17 @@ QString SiteNameFromUrl(const QString &url) { return QString(); } +bool ShowButton() { + static const auto Supported = Webview::NavigateToDataSupported(); + return Supported; +} + +void RecordShowFailure() { + FailureRecorded = true; +} + +bool FailedToShow() { + return FailureRecorded; +} + } // namespace Iv diff --git a/Telegram/SourceFiles/iv/iv_data.h b/Telegram/SourceFiles/iv/iv_data.h index 6e2db12ca7..c33fe1b182 100644 --- a/Telegram/SourceFiles/iv/iv_data.h +++ b/Telegram/SourceFiles/iv/iv_data.h @@ -53,4 +53,9 @@ private: [[nodiscard]] QString SiteNameFromUrl(const QString &url); +[[nodiscard]] bool ShowButton(); + +void RecordShowFailure(); +[[nodiscard]] bool FailedToShow(); + } // namespace Iv diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index a24ce6867d..c2ebb2f2ac 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -1060,4 +1060,4 @@ boostsMessageIcon: icon {{ "stories/boosts_mini", windowFg }}; boostsMessageIconPadding: margins(0px, 2px, 0px, 0px); historyIvIcon: icon{{ "boosts/boost_mini2", windowFg }}; -historyIvIconPadding: margins(2px, 3px, 2px, 0px); +historyIvIconPadding: margins(2px, 2px, 2px, 0px); diff --git a/Telegram/lib_webview b/Telegram/lib_webview index fbf9dd5478..cf8ef94d0b 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit fbf9dd54787df90c98cf230cb53323527e0b0639 +Subproject commit cf8ef94d0b12f8484e247d6a2d88dd1c11a6b964