From 8cbeadc68a88acb207305ad02e6c01df3a80b690 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jul 2024 13:22:33 +0400 Subject: [PATCH 01/36] Register tg:// scheme on initial launch. --- Telegram/SourceFiles/core/application.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index 21d3aa7ca310e..c33b24c2af2e3 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -261,9 +261,14 @@ void Application::run() { refreshGlobalProxy(); // Depends on app settings being read. - if (const auto old = Local::oldSettingsVersion(); old < AppVersion) { + if (const auto old = Local::oldSettingsVersion()) { + if (old < AppVersion) { + InvokeQueued(this, [] { RegisterUrlScheme(); }); + Platform::NewVersionLaunched(old); + } + } else { + // Initial launch. InvokeQueued(this, [] { RegisterUrlScheme(); }); - Platform::NewVersionLaunched(old); } if (cAutoStart() && !Platform::AutostartSupported()) { From 17bb430006c155305dbb5407fd3d081326af9b1b Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jul 2024 13:34:52 +0400 Subject: [PATCH 02/36] Register tg:// scheme on first launch. Also, allow disabling tg:// re-registration on update. --- Telegram/SourceFiles/core/application.cpp | 19 +++++++++++++++++-- Telegram/SourceFiles/core/application.h | 3 +++ .../settings/settings_experimental.cpp | 1 + 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index c33b24c2af2e3..e3e0de6c6e1a3 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -19,6 +19,7 @@ For license and copyright information please follow this link: #include "base/battery_saving.h" #include "base/event_filter.h" #include "base/concurrent_timer.h" +#include "base/options.h" #include "base/qt_signal_producer.h" #include "base/timer.h" #include "base/unixtime.h" @@ -140,10 +141,18 @@ void SetCrashAnnotationsGL() { #endif // DESKTOP_APP_USE_ANGLE } +base::options::toggle OptionSkipUrlSchemeRegister({ + .id = kOptionSkipUrlSchemeRegister, + .name = "Skip URL scheme register", + .description = "Don't re-register tg:// URL scheme on autoupdate.", +}); + } // namespace Application *Application::Instance = nullptr; +const char kOptionSkipUrlSchemeRegister[] = "skip-url-scheme-register"; + struct Application::Private { base::Timer quitTimer; UiIntegration uiIntegration; @@ -263,12 +272,12 @@ void Application::run() { if (const auto old = Local::oldSettingsVersion()) { if (old < AppVersion) { - InvokeQueued(this, [] { RegisterUrlScheme(); }); + autoRegisterUrlScheme(); Platform::NewVersionLaunched(old); } } else { // Initial launch. - InvokeQueued(this, [] { RegisterUrlScheme(); }); + autoRegisterUrlScheme(); } if (cAutoStart() && !Platform::AutostartSupported()) { @@ -410,6 +419,12 @@ void Application::run() { processCreatedWindow(_lastActivePrimaryWindow); } +void Application::autoRegisterUrlScheme() { + if (!OptionSkipUrlSchemeRegister.value()) { + InvokeQueued(this, [] { RegisterUrlScheme(); }); + } +} + void Application::showAccount(not_null account) { if (const auto separate = separateWindowFor(account)) { _lastActivePrimaryWindow = separate; diff --git a/Telegram/SourceFiles/core/application.h b/Telegram/SourceFiles/core/application.h index 77fe09b7ff00d..eca07e75193ff 100644 --- a/Telegram/SourceFiles/core/application.h +++ b/Telegram/SourceFiles/core/application.h @@ -126,6 +126,8 @@ enum class QuitReason { QtQuitEvent, }; +extern const char kOptionSkipUrlSchemeRegister[]; + class Application final : public QObject { public: struct ProxyChange { @@ -349,6 +351,7 @@ class Application final : public QObject { friend bool IsAppLaunched(); friend Application &App(); + void autoRegisterUrlScheme(); void clearEmojiSourceImages(); [[nodiscard]] auto prepareEmojiSourceImages() -> std::shared_ptr; diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp b/Telegram/SourceFiles/settings/settings_experimental.cpp index 93e9e74dc27b6..f578bce829fa3 100644 --- a/Telegram/SourceFiles/settings/settings_experimental.cpp +++ b/Telegram/SourceFiles/settings/settings_experimental.cpp @@ -152,6 +152,7 @@ void SetupExperimental( addToggle(kOptionAutoScrollInactiveChat); addToggle(Window::Notifications::kOptionGNotification); addToggle(Core::kOptionFreeType); + addToggle(Core::kOptionSkipUrlSchemeRegister); addToggle(Data::kOptionExternalVideoPlayer); addToggle(Window::kOptionNewWindowsSizeAsFirst); } From ec2faca14502fa907b503ecba7834ccf5419ad82 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jul 2024 18:08:24 +0400 Subject: [PATCH 03/36] Fix couple of crashes in secondary windows. --- .../boxes/peers/edit_peer_info_box.cpp | 5 ++++- Telegram/SourceFiles/mainwidget.cpp | 19 +++++++++++-------- Telegram/SourceFiles/mainwidget.h | 3 +-- .../window/window_session_controller.cpp | 13 ++++++++++--- 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index b27665ac88c57..0ba6354f996bd 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -2200,8 +2200,11 @@ void Controller::saveForum() { channel->inputChannel, MTP_bool(*_savingData.forum) )).done([=](const MTPUpdates &result) { + const auto weak = base::make_weak(this); channel->session().api().applyUpdates(result); - continueSave(); + if (weak) { // todo better to be able to save in closed already box. + continueSave(); + } }).fail([=](const MTP::Error &error) { if (error.type() == u"CHAT_NOT_MODIFIED"_q) { continueSave(); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index 45ad3ef62fd5b..854441b8c2184 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -1192,9 +1192,11 @@ void MainWidget::setInnerFocus() { _mainSection->setInnerFocus(); } else if (!_hider && _thirdSection) { _thirdSection->setInnerFocus(); - } else { - Assert(_dialogs != nullptr); + } else if (_dialogs) { _dialogs->setInnerFocus(); + } else { + // Maybe we're just closing a child window, content is destroyed. + _history->setFocus(); } } else if (_mainSection) { _mainSection->setInnerFocus(); @@ -1293,8 +1295,9 @@ void MainWidget::showHistory( } const auto unavailable = peer->computeUnavailableReason(); if (!unavailable.isEmpty()) { - Assert(isPrimary()); // windows todo - if (params.activation != anim::activation::background) { + if (!isPrimary()) { + _controller->window().close(); + } else if (params.activation != anim::activation::background) { _controller->show(Ui::MakeInformBox(unavailable)); _controller->window().activate(); } @@ -1950,10 +1953,9 @@ void MainWidget::showNonPremiumLimitToast(bool download) { }); } -void MainWidget::showBackFromStack( - const SectionShow ¶ms) { +bool MainWidget::showBackFromStack(const SectionShow ¶ms) { if (preventsCloseSection([=] { showBackFromStack(params); }, params)) { - return; + return false; } if (_stack.empty()) { @@ -1963,7 +1965,7 @@ void MainWidget::showBackFromStack( crl::on_main(this, [=] { _controller->widget()->setInnerFocus(); }); - return; + return (_dialogs != nullptr); } auto item = std::move(_stack.back()); _stack.pop_back(); @@ -1995,6 +1997,7 @@ void MainWidget::showBackFromStack( anim::activation::background)); } + return true; } void MainWidget::orderWidgets() { diff --git a/Telegram/SourceFiles/mainwidget.h b/Telegram/SourceFiles/mainwidget.h index b97c7f98fba95..7acbbead4e174 100644 --- a/Telegram/SourceFiles/mainwidget.h +++ b/Telegram/SourceFiles/mainwidget.h @@ -152,8 +152,7 @@ class MainWidget final const SectionShow ¶ms); void updateColumnLayout(); bool stackIsEmpty() const; - void showBackFromStack( - const SectionShow ¶ms); + bool showBackFromStack(const SectionShow ¶ms); void orderWidgets(); QPixmap grabForShowAnimation(const Window::SectionSlideParams ¶ms); void checkMainSectionToLayer(); diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 017fb7fd0f445..8380e458a1039 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1660,8 +1660,9 @@ void SessionController::showForum( ) | rpl::start_with_next([=, history = forum->history()] { const auto now = activeChatCurrent().owningHistory(); const auto showHistory = !now || (now == history); + const auto weak = base::make_weak(this); closeForum(); - if (showHistory) { + if (weak && showHistory) { showPeerHistory(history, { SectionShow::Way::Backward, anim::type::normal, @@ -1676,7 +1677,7 @@ void SessionController::closeForum() { if (const auto forum = _shownForum.current()) { const auto id = windowId(); if (id.type == SeparateType::Forum) { - const auto initial = id.thread->asForum(); + const auto initial = id.forum(); if (!initial || initial == forum) { Core::App().closeWindow(_window); } else { @@ -2529,7 +2530,13 @@ void SessionController::showBackFromStack(const SectionShow ¶ms) { return topic && topic->forum()->topicDeleted(topic->rootId()); }; do { - content()->showBackFromStack(params); + const auto empty = content()->stackIsEmpty(); + const auto shown = content()->showBackFromStack(params); + if (empty && !shown && content()->stackIsEmpty() && bad()) { + clearSectionStack(anim::type::instant); + window().close(); + break; + } } while (bad()); } From a507d28b49d8fabdb15a75790822f00133de7099 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 2 Jul 2024 19:03:07 +0400 Subject: [PATCH 04/36] Version 5.2.2. - Fix topics search in topic groups. - Fix Instant View pages content updating. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 8 ++++---- changelog.txt | 5 +++++ 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 5e910709051fc..53203464b97ab 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -10,7 +10,7 @@ + Version="5.2.2.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index b08e52bf99d57..2d9446598cc8f 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 5,2,1,0 - PRODUCTVERSION 5,2,1,0 + FILEVERSION 5,2,2,0 + PRODUCTVERSION 5,2,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "5.2.1.0" + VALUE "FileVersion", "5.2.2.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "5.2.1.0" + VALUE "ProductVersion", "5.2.2.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index a62f79c3b47dd..abd5f4d0e0a06 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 5,2,1,0 - PRODUCTVERSION 5,2,1,0 + FILEVERSION 5,2,2,0 + PRODUCTVERSION 5,2,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "5.2.1.0" + VALUE "FileVersion", "5.2.2.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "5.2.1.0" + VALUE "ProductVersion", "5.2.2.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 994bba9688431..57252c888c8ac 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 5002001; -constexpr auto AppVersionStr = "5.2.1"; +constexpr auto AppVersion = 5002002; +constexpr auto AppVersionStr = "5.2.2"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index 7e6b267c080bf..5531916133f43 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 5002001 +AppVersion 5002002 AppVersionStrMajor 5.2 -AppVersionStrSmall 5.2.1 -AppVersionStr 5.2.1 +AppVersionStrSmall 5.2.2 +AppVersionStr 5.2.2 BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 5.2.1 +AppVersionOriginal 5.2.2 diff --git a/changelog.txt b/changelog.txt index 7cc1ef676ddb5..6e398bcc664f5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +5.2.2 (02.07.24) + +- Fix topics search in topic groups. +- Fix Instant View pages content updating. + 5.2.1 (01.07.24) - Fix crash when opening topic in a new window. From e6e1b9446d692d1e8b8869edb2c9bc6427bb6773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Wed, 3 Jul 2024 16:38:23 +0200 Subject: [PATCH 05/36] Upgrade libjxl on Linux to 0.10.3 --- Telegram/build/docker/centos_env/Dockerfile | 2 +- snap/snapcraft.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 2b0c82ed0d562..71c9533ebe736 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -250,7 +250,7 @@ COPY --link --from=lcms2 {{ LibrariesPath }}/lcms2-cache / COPY --link --from=brotli {{ LibrariesPath }}/brotli-cache / COPY --link --from=highway {{ LibrariesPath }}/highway-cache / -RUN git clone -b v0.10.2 --depth=1 {{ GIT }}/libjxl/libjxl.git \ +RUN git clone -b v0.10.3 --depth=1 {{ GIT }}/libjxl/libjxl.git \ && cd libjxl \ && git apply ../patches/libjxl.patch \ && git submodule update --init --recursive --depth=1 third_party/libjpeg-turbo \ diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 454da33b19d0d..033424e1d6fb7 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -237,7 +237,7 @@ parts: libjxl: source: https://github.com/libjxl/libjxl.git source-depth: 1 - source-tag: v0.10.2 + source-tag: v0.10.3 plugin: cmake build-environment: - LDFLAGS: ${LDFLAGS:+$LDFLAGS} -s From 9ca990473232ff0dced5fbdb9f848bae61a0b797 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Thu, 4 Jul 2024 09:12:54 +0200 Subject: [PATCH 06/36] Upgrade libjxl to v0.10.3 --- Telegram/build/prepare/prepare.py | 8 +++----- cmake | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 60d60ea473c7c..8b1f71c68f956 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -938,7 +938,7 @@ def runStages(): """) stage('libjxl', """ - git clone -b v0.8.2 --recursive --shallow-submodules https://github.com/libjxl/libjxl.git + git clone -b v0.10.3 --recursive --shallow-submodules https://github.com/libjxl/libjxl.git cd libjxl """ + setVar("cmake_defines", """ -DBUILD_SHARED_LIBS=OFF @@ -954,12 +954,10 @@ def runStages(): -DJPEGXL_ENABLE_SJPEG=OFF -DJPEGXL_ENABLE_OPENEXR=OFF -DJPEGXL_ENABLE_SKCMS=ON - -DJPEGXL_BUNDLE_SKCMS=ON -DJPEGXL_ENABLE_VIEWERS=OFF -DJPEGXL_ENABLE_TCMALLOC=OFF -DJPEGXL_ENABLE_PLUGINS=OFF -DJPEGXL_ENABLE_COVERAGE=OFF - -DJPEGXL_ENABLE_PROFILER=OFF -DJPEGXL_WARNINGS_AS_ERRORS=OFF """) + """ win: @@ -967,8 +965,8 @@ def runStages(): -A %WIN32X64% ^ -DCMAKE_INSTALL_PREFIX=%LIBS_DIR%/local ^ -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$:Debug>" ^ - -DCMAKE_C_FLAGS="/DJXL_STATIC_DEFINE /DJXL_THREADS_STATIC_DEFINE" ^ - -DCMAKE_CXX_FLAGS="/DJXL_STATIC_DEFINE /DJXL_THREADS_STATIC_DEFINE" ^ + -DCMAKE_C_FLAGS="/DJXL_STATIC_DEFINE /DJXL_THREADS_STATIC_DEFINE /DJXL_CMS_STATIC_DEFINE" ^ + -DCMAKE_CXX_FLAGS="/DJXL_STATIC_DEFINE /DJXL_THREADS_STATIC_DEFINE /DJXL_CMS_STATIC_DEFINE" ^ -DCMAKE_C_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ -DCMAKE_CXX_FLAGS_DEBUG="/MTd /Zi /Ob0 /Od /RTC1" ^ -DCMAKE_C_FLAGS_RELEASE="/MT /O2 /Ob2 /DNDEBUG" ^ diff --git a/cmake b/cmake index 5742caae65e41..4a4bc4cd34b3a 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 5742caae65e4163e7faec238eb4e3e5c219ad09c +Subproject commit 4a4bc4cd34b3ade038541a2b8b2c79f05393d67b From 8d0d9bb0bd2fbeb8ef826e582bef5b0620950620 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 6 Jul 2024 00:43:18 +0400 Subject: [PATCH 07/36] Delay clearing transient parent until the pip window is really exposed --- Telegram/SourceFiles/media/view/media_view_pip.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/media/view/media_view_pip.cpp b/Telegram/SourceFiles/media/view/media_view_pip.cpp index 0975b5c6f101e..da359769fa7bf 100644 --- a/Telegram/SourceFiles/media/view/media_view_pip.cpp +++ b/Telegram/SourceFiles/media/view/media_view_pip.cpp @@ -351,10 +351,14 @@ void PipPanel::init() { widget()->resize(0, 0); widget()->hide(); - rp()->shownValue( - ) | rpl::filter([=](bool shown) { - return shown; - }) | rpl::start_with_next([=] { + rpl::merge( + rp()->shownValue() | rpl::to_empty, + rp()->paintRequest() | rpl::to_empty + ) | rpl::map([=] { + return widget()->windowHandle() + && widget()->windowHandle()->isExposed(); + }) | rpl::distinct_until_changed( + ) | rpl::filter(rpl::mappers::_1) | rpl::start_with_next([=] { // Workaround Qt's forced transient parent. Ui::Platform::ClearTransientParent(widget()); }, rp()->lifetime()); From aa140b2919c46c0e0f0117f59bbf946aa3124043 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 3 Jul 2024 22:55:10 +0400 Subject: [PATCH 08/36] Fix warnings on Windows --- .../history/view/history_view_pinned_bar.cpp | 4 ++-- .../media/history_view_similar_channels.cpp | 4 ++-- .../SourceFiles/platform/win/specific_win.cpp | 7 +++---- Telegram/SourceFiles/platform/win/tray_win.h | 2 +- .../details/storage_settings_scheme.cpp | 2 +- Telegram/cmake/lib_tgvoip.cmake | 21 +++++++------------ 6 files changed, 16 insertions(+), 24 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_pinned_bar.cpp b/Telegram/SourceFiles/history/view/history_view_pinned_bar.cpp index d530e4779b894..eebbb18480015 100644 --- a/Telegram/SourceFiles/history/view/history_view_pinned_bar.cpp +++ b/Telegram/SourceFiles/history/view/history_view_pinned_bar.cpp @@ -76,9 +76,9 @@ namespace { return rpl::single(ContentWithoutPreview(item, repaint)); } constexpr auto kFullLoaded = 2; - constexpr auto kSomeLoaded = 1; - constexpr auto kNotLoaded = 0; const auto loadedLevel = [=] { + constexpr auto kSomeLoaded = 1; + constexpr auto kNotLoaded = 0; const auto preview = media->replyPreview(); return media->replyPreviewLoaded() ? kFullLoaded diff --git a/Telegram/SourceFiles/history/view/media/history_view_similar_channels.cpp b/Telegram/SourceFiles/history/view/media/history_view_similar_channels.cpp index 05a03df4dc03a..aa14b12c1b5f9 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_similar_channels.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_similar_channels.cpp @@ -167,7 +167,7 @@ void SimilarChannels::draw(Painter &p, const PaintContext &context) const { _hasHeavyPart = 1; validateLastPremiumLock(); const auto drawOne = [&](const Channel &channel) { - const auto geometry = channel.geometry.translated(-_scrollLeft, 0); + const auto geometry = channel.geometry.translated(-int(_scrollLeft), 0); const auto right = geometry.x() + geometry.width(); if (right <= 0) { return; @@ -501,7 +501,7 @@ TextState SimilarChannels::textState( return result; } for (const auto &channel : _channels) { - if (channel.geometry.translated(-_scrollLeft, 0).contains(point)) { + if (channel.geometry.translated(-int(_scrollLeft), 0).contains(point)) { result.link = channel.link; _lastPoint = point + QPoint(_scrollLeft, 0) diff --git a/Telegram/SourceFiles/platform/win/specific_win.cpp b/Telegram/SourceFiles/platform/win/specific_win.cpp index 7a3b133c49d0e..a35cfd3c44e22 100644 --- a/Telegram/SourceFiles/platform/win/specific_win.cpp +++ b/Telegram/SourceFiles/platform/win/specific_win.cpp @@ -98,7 +98,6 @@ BOOL CALLBACK FindToActivate(HWND hwnd, LPARAM lParam) { return TRUE; } // Found a Top-Level window. - auto level = 0; if (WindowIdFromHWND(hwnd) == request->windowId) { request->result = hwnd; request->resultLevel = 3; @@ -310,8 +309,8 @@ void psDoFixPrevious() { if (oldKeyRes2 == ERROR_SUCCESS) RegCloseKey(oldKey2); if (existNew1 || existNew2) { - const auto deleteKeyRes1 = existOld1 ? RegDeleteKey(HKEY_LOCAL_MACHINE, oldKeyStr1.c_str()) : ERROR_SUCCESS; - const auto deleteKeyRes2 = existOld2 ? RegDeleteKey(HKEY_LOCAL_MACHINE, oldKeyStr2.c_str()) : ERROR_SUCCESS; + if (existOld1) RegDeleteKey(HKEY_LOCAL_MACHINE, oldKeyStr1.c_str()); + if (existOld2) RegDeleteKey(HKEY_LOCAL_MACHINE, oldKeyStr2.c_str()); } QString userDesktopLnk, commonDesktopLnk; @@ -326,7 +325,7 @@ void psDoFixPrevious() { } QFile userDesktopFile(userDesktopLnk), commonDesktopFile(commonDesktopLnk); if (QFile::exists(userDesktopLnk) && QFile::exists(commonDesktopLnk) && userDesktopLnk != commonDesktopLnk) { - bool removed = QFile::remove(commonDesktopLnk); + QFile::remove(commonDesktopLnk); } } catch (...) { } diff --git a/Telegram/SourceFiles/platform/win/tray_win.h b/Telegram/SourceFiles/platform/win/tray_win.h index cb79c3beb5aef..aed4cc6e3442d 100644 --- a/Telegram/SourceFiles/platform/win/tray_win.h +++ b/Telegram/SourceFiles/platform/win/tray_win.h @@ -12,7 +12,7 @@ For license and copyright information please follow this link: #include "base/unique_qptr.h" namespace Window { -class CounterLayerArgs; +struct CounterLayerArgs; } // namespace Window namespace Ui { diff --git a/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp b/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp index 9baca321c93fc..695f8f58aa2cf 100644 --- a/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp +++ b/Telegram/SourceFiles/storage/details/storage_settings_scheme.cpp @@ -553,7 +553,7 @@ bool ReadSetting( const auto proxy = readProxy(); if (proxy) { list.push_back(proxy); - } else if (index < -list.size()) { + } else if (index < -int64(list.size())) { ++index; } else if (index > list.size()) { --index; diff --git a/Telegram/cmake/lib_tgvoip.cmake b/Telegram/cmake/lib_tgvoip.cmake index 886cd9935beb6..fbae709660848 100644 --- a/Telegram/cmake/lib_tgvoip.cmake +++ b/Telegram/cmake/lib_tgvoip.cmake @@ -134,20 +134,13 @@ PRIVATE ) if (WIN32) - if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - target_compile_options(lib_tgvoip_bundled - PRIVATE - /wd4005 - /wd4244 # conversion from 'int' to 'float', possible loss of data (several in webrtc) - /wd5055 # operator '>' deprecated between enumerations and floating-point types - ) - else() - target_compile_definitions(lib_tgvoip_bundled - PUBLIC - # Doesn't build with mingw for now - TGVOIP_NO_DSP - ) - endif() + target_compile_options_if_exists(lib_tgvoip_bundled + PRIVATE + /wd4005 # 'identifier' : macro redefinition + /wd4068 # unknown pragma + /wd4996 # deprecated + /wd5055 # operator '>' deprecated between enumerations and floating-point types + ) elseif (APPLE) target_compile_definitions(lib_tgvoip_bundled PUBLIC From bf7042df4456302f2104fb41afcaa5c5dfaf3662 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 3 Jul 2024 22:55:30 +0400 Subject: [PATCH 09/36] Enable warnings as errors on Windows --- .github/workflows/win.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/win.yml b/.github/workflows/win.yml index ca0c7bf097016..6de53f12d658e 100644 --- a/.github/workflows/win.yml +++ b/.github/workflows/win.yml @@ -169,6 +169,8 @@ jobs: %TDESKTOP_BUILD_GENERATOR% ^ %TDESKTOP_BUILD_ARCH% ^ %TDESKTOP_BUILD_API% ^ + -D CMAKE_C_FLAGS="/WX" ^ + -D CMAKE_CXX_FLAGS="/WX" ^ -D DESKTOP_APP_DISABLE_AUTOUPDATE=OFF ^ -D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF ^ -D DESKTOP_APP_NO_PDB=ON ^ From 054a6db3aee58d2cd024e747bfba9c29f19b13b3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 11:07:07 +0400 Subject: [PATCH 10/36] Fix warnings on Windows in submodules. --- Telegram/lib_base | 2 +- Telegram/lib_ui | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/lib_base b/Telegram/lib_base index f30400147d997..1a50fd2300da3 160000 --- a/Telegram/lib_base +++ b/Telegram/lib_base @@ -1 +1 @@ -Subproject commit f30400147d997fedc787e214467d305db6c159e7 +Subproject commit 1a50fd2300da3198e751a22bf728d33822180e15 diff --git a/Telegram/lib_ui b/Telegram/lib_ui index ebd8609ee73d4..067733899d62c 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit ebd8609ee73d48186b905787dd5bb3bcbb4f9f3f +Subproject commit 067733899d62caa5411f54904a431d3484fd02e3 From 66d6b461f39013ba710e978aba2296f3d4a0e56c Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 4 Jul 2024 09:34:27 +0300 Subject: [PATCH 11/36] Fixed support type of credits history entry for ads in earn section. --- Telegram/SourceFiles/ui/effects/credits.style | 2 ++ Telegram/SourceFiles/ui/effects/credits_graphics.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Telegram/SourceFiles/ui/effects/credits.style b/Telegram/SourceFiles/ui/effects/credits.style index e78642348db62..baab38fb77279 100644 --- a/Telegram/SourceFiles/ui/effects/credits.style +++ b/Telegram/SourceFiles/ui/effects/credits.style @@ -47,3 +47,5 @@ creditsBoxButtonLabel: FlatLabel(defaultFlatLabel) { starIconSmall: icon{{ "payments/small_star", windowFg }}; starIconSmallPadding: margins(0px, -2px, 0px, 0px); + +creditsHistoryEntryTypeAds: icon {{ "folders/folders_channels", premiumButtonFg }}; diff --git a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp index 9f48191f0299b..3f4ce02f2ca90 100644 --- a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp +++ b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp @@ -205,6 +205,8 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( return { st::historyPeer8UserpicBg, st::historyPeer8UserpicBg2 }; case Data::CreditsHistoryEntry::PeerType::PremiumBot: return { st::historyPeer8UserpicBg, st::historyPeer8UserpicBg2 }; + case Data::CreditsHistoryEntry::PeerType::Ads: + return { st::historyPeer6UserpicBg, st::historyPeer6UserpicBg2 }; case Data::CreditsHistoryEntry::PeerType::Unsupported: return { st::historyPeerArchiveUserpicBg, @@ -227,6 +229,8 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( ? st::sessionIconAndroid : (entry.peerType == PeerType::Fragment) ? st::introFragmentIcon + : (entry.peerType == PeerType::Ads) + ? st::creditsHistoryEntryTypeAds : st::dialogsInaccessibleUserpic).paintInCenter(p, rect); }; } @@ -442,6 +446,8 @@ Fn)> PaintPreviewCallback( TextWithEntities GenerateEntryName(const Data::CreditsHistoryEntry &entry) { return ((entry.peerType == Data::CreditsHistoryEntry::PeerType::Fragment) ? tr::lng_bot_username_description1_link + : (entry.peerType == Data::CreditsHistoryEntry::PeerType::Ads) + ? tr::lng_credits_box_history_entry_ads : tr::lng_credits_summary_history_entry_inner_in)( tr::now, TextWithEntities::Simple); From b377c02ad38d5043cbfaab37b3db7a86cfe381c9 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 4 Jul 2024 10:07:18 +0300 Subject: [PATCH 12/36] Added support of min boost level for channel ads to feature list. --- .../premium/features/feature_off_sponsored.png | Bin 0 -> 771 bytes .../features/feature_off_sponsored@2x.png | Bin 0 -> 1540 bytes .../features/feature_off_sponsored@3x.png | Bin 0 -> 2194 bytes .../boxes/peers/replace_boost_box.cpp | 1 + Telegram/SourceFiles/ui/boxes/boost_box.cpp | 11 +++++++++-- Telegram/SourceFiles/ui/boxes/boost_box.h | 1 + Telegram/SourceFiles/ui/effects/premium.style | 1 + 7 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 Telegram/Resources/icons/settings/premium/features/feature_off_sponsored.png create mode 100644 Telegram/Resources/icons/settings/premium/features/feature_off_sponsored@2x.png create mode 100644 Telegram/Resources/icons/settings/premium/features/feature_off_sponsored@3x.png diff --git a/Telegram/Resources/icons/settings/premium/features/feature_off_sponsored.png b/Telegram/Resources/icons/settings/premium/features/feature_off_sponsored.png new file mode 100644 index 0000000000000000000000000000000000000000..06a33dc3c089717f0c8ad67beca035d1daea3184 GIT binary patch literal 771 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1SIoCSFHz9jKx9jP7LeL$-D$|Tv8)E(|mmy zw18|52FCVG1{RPKAeI7R1_tH@j10^`nh_+nfC(-uv49!D1}S`GTDq2jfhpJ1#WBP} z@NS5$$Erk;bMvQMaB<}3bQMwMIJlc*nzQ`{F%6D~HJvgnf+n{_SR7?aiUf04EY#$2 z(a02g%uR)5W`wIx)}BT^m+iUw=PudwhKS`Sa)Po0YpyKb<#k z-nS~-_QMAm`eSzQ-hDRh^P4w5I%4|z`io`$*fLA5bzK~Ipl-kX1{Wnm37-9SDq`IW z1*V^NRZ3j9e!cMIFg`v$wq{2gx#K!!=H}A9Y(dWR=FjhSdu%e>>xk-&fB)>V_*$K& zdZ|wI(9zRdBwmr0o^IF&v}pEhX{UdyHgulO+RDYkG~@X33)zw!sN(u`bU8H)|=AYM|>eYYz^Or9!M}t?YcWT^w`}XavTT;KY zM7Xr3zIySZLn+{yieQ+wQ0KCTK`XcH+SN7jX_2MIn_?kM~Sob(CO2s zw{JI}eb$Wk;Nd<0cJADnW7fTN(FA+>Cf}JpY9S#Fsl%T?e_k8L{aSvux3@P(n1)Esx8Ejr z^UTkQHXomCH2bW@U&G#?<}-aJv1?8~If0|xVMW<)S>IG6NtwI+@;o{#Zogf(W{pCG z)>Ng5e#@0R1@>&++A0c+C}!2VG}WnIQ%^tjP-(i9wN+~V`Q;TAr!Baz`2EbBeEhMj toZPa@nL6BtCN`S_&s~pBO!@cv-2T3`qBhw)RyRQj(9_k=Wt~$(69A{aJm3HT literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/settings/premium/features/feature_off_sponsored@2x.png b/Telegram/Resources/icons/settings/premium/features/feature_off_sponsored@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..996851dbc9f57f50181b43546053c9f9a7389393 GIT binary patch literal 1540 zcmV+f2K)JmP)Px#L}ge>W=%~1DgXcg2mk?xX#fNO00031000^Q000001E2u_0{{R30RRC20H6W@ z1ONa40RR91FrWhf1ONa40RR91FaQ7m0NXcg3;+NHZb?KzR9Fe^SXn5hZ5U>3VeFD6 zOUM?b$Tl%UYRs4j2ew2)NLdQWgsD+z!~q8s2TGVDLu!yEJK2+xiG!K3jAm?OU;h94 z-FfDn?|r?#@B8QAuity{d7gW@?)!b7dwVG;JUkC4@NfeEvlCF{zpt8_+S%C|pDs5= zOG_&)EzQl%O<7sFySux!we{fOKw30kU*EmGy}7wLTU%RcbwuUD!ot3P|Na-}SzcbY zw6qje;xO~`^GWyHw{Pz5?i`NHOI20X>gsCd$@uvA%*+gJ@xqFV0+%CTLtkHiVPS#P ze*XOV{P}YMAt^{!R#uaflZ3OevGMHLGg5l}`ZW;)0|TXixe?LP(HR&RAhq-J^SHP; zX*F- zii%2QWhE(IU0oFw6+L?NNJ4jie;)!RB_$Gc+A0fDk!4X)QQO}&u*UQbUiC@4rnLxZoIl$7M<dq6Y=3`0U*=y?3JMD7b@AKQ)`mDGI1394 zBnx9nEZ~Q+vGHAo#ZO3Bi+j%T@$q!)unJ4s+S;Up@E;u=m2d^yw{PEa)%gbGap=vP zH{76m@!|zCj%?4*&zqQ-Ff+I~xQGYxB!Kv1T)~CR4%yh)(2*o3Co@D3509Ol9WuGT zzHV=C&selbPf!0N4oRi}&_hB(P~)-a>+54yr>3TSe0<;vD5x>GEKg5Q#{Gi}0f(%u ztziIZvbMIywY0jr3ZGD9K{PNhKs*Hp2Qz`e!9nCX+seHVa7bNU9dM{@d{B7#^yyPN zIYdu;dwXJHB8egC!o$N)PEPn*GEoE^64yUGJbd}`B|0|5aI*~!4TXh;q|(vRAwxsB z!;H)h0SEmgCMKq;s){g?=e4!9lqk?HI(my1Hoa#mhuTM}PS6fv*LJ(EHFX?;45tD*sSiTwG>nXX%Z_e{nEW+@baO z@#BvlKa%|A-Qd=Wy*wi*x+KtTgBOa$iU z=91`g?D1xZTp-re)JUj1I5?0)7;`09Y>U^}+}tFwFJHc(crup!ijsiK#fB(G&G!;m>^-CH<~er zDc2JJNdX)Zr?j+`zK-$nMJETkH2=`Rkcm=GK4GRn{K@6WtrGeP3LwGZmwl{ZjbZ3k z>Yl$CG8-Ek2}Jys?*Sq3H%L+7`mZr(d-}q0000|TbjT(v>&wrcot+Wq98oSKdqi0$d)#rHLeeFq zIwPm^wb#k~efs_J`~LBM-p?Md=kp4D>6oQxumJ)w9vkWD-1k1WmLE3E;5qtsYjSwg(w6qwo8Ql#}BRR*bs_I5s-}f<*Q7{Z)^Wd z7=~msUSZc0esU+vUf3|tK9MUsCpY(g4ZKv=t~vVj_;&Vh{}3gw4~`|;;I;|))?}Rx zxy6Tj|9Eeiw!Jj6G?JGGwSt05^VtSMB`D5-%Rr}8JlM7#J<>*N1dV4OsrOQ)-flCZyOzeiZxGY8{{i&k^8GN0?M8((@SFov~L|DN?*%iXg$JkVLFeDX5^;!G`KtF zsMU2KMVEsK-X1tF4$JhGetoYie2s;oYVS=MEAYxVjMZBKR!tJe0jKK%cuDDw@vz`cKa7YlTZ>=cE6eJYwbUV5{li`A z<(jh+!nsto%faPaspGlQBw+rx&I#3~1r#*0?7D5E=zE`(?(xfNp>PSd68V9rm-(mR zetq>$UDqFUM-FF+DXF^l(|<}#fH0mO|F+C}$o!a*{kl_Ui;EEWW=L=J?}xv3sif~+ z5q%LGFI_AyVN`schAVG=C{kB6_y@o3Khr!Yx)bTx=%SOtBA~)}YkDfZLosL&KHM#e0wOcd$!WNb30oaFnvA~y0>eB83A#DziRg_GBI*j@OYz^oLiUX{*c zhLp&%{Xrz3zD;}pxi{*k`WeqaI3U zP_zGJ?IeJ@#}(Y#Y}?w5I~`5Ud0umv2P;bk-~pC!?v518#MLem(Uy^1ETBrp6Mj{p zZr2(^u^O`?H6VOA!)8#cM&VU1{S3N_ER{2{(^c-$=1I1?dd#yD$T-^+e9_#8f{p;P zW>eCyaRG%#yWaoX;yz{U66fkI?zXEImENSPvCgo6lGv+nE=d`K_7@$zbs1Nt8szb) zBdh-HM%VRk9sTd=t|<_s`Yv|#mX(bLgH%f@74&jR#B4~I?B^Qu@{CWcT`GwE)h5b` zx-iDI(Gly3ip;+dcb>)$Q)X;Ypa%j=_c#VE$|_@7m0_JcAk~y-`ps;qXw_tP=oP%x z&rWO;6fNL+buPS@UhzQ$-d!r95$iR+B5rH2hMOpd0R(N>nyj@dUwEMv7poI25HQ;+ z_ZEs*rQ;v+C=@%s6nFLK@QR4UtD^lTXG}fan3!C=M_<@K&nbWL8pOW#S#50K!QP7) zf@?_}`dUTf0kVDZ(Nx;hxLff8ehi$p7<-^K4QF|*EY}Q>mfRQT?8~iX^3sDa2@uh( z5$}3@u;t&H?17O)J6hi_P0)r79aSR(bN|Y~BIP>&o`kx3gOR*)WlBD`U6{ zbB<8E<_aeWib|?R|N7n=gV1=07ZOwU9OV$aPy&9_(7`K7#oRE~{LeBsD8(B2ONU4( z5Z8|q0|3Wf+S;5SK=mqrT^@a5Ng|b$;+flkQ2#sHMFAyAT_#a>{R_iar_EW)RTfJ1 z0A;;a%%q3|)R>Ckx2y^DpKTq}X4tP$=0ecSk@N9fPSQfZ#MDPwpViiVgmBco&yx>; ze|c?3!qM*!4?Z9uj?g2Oa5jDg(JBT&>0*x$noPhYAr62HVz?pV?NK{bk}r3N;$(4s z4ms&Eg80i$XfeaEEGWF!eQs-x!eOORv-c5@)YmZGRwCZ`{8em*t$ZZJFB_Hx}D{}2fRXiy4hpNN2TCba^$zFReO!!Z9o#vD;|aZ3q(;DZ4jEgQL|i9i1V NBYiWydR>>q{{ktQFPs1X literal 0 HcmV?d00001 diff --git a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp index 70648d627aa24..a3bc8b69bd374 100644 --- a/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/replace_boost_box.cpp @@ -459,6 +459,7 @@ Ui::BoostFeatures LookupBoostFeatures(not_null channel) { .customWallpaperLevel = group ? levelLimits.groupCustomWallpaperLevelMin() : levelLimits.channelCustomWallpaperLevelMin(), + .sponsoredLevel = levelLimits.channelRestrictSponsoredLevelMin(), }; } diff --git a/Telegram/SourceFiles/ui/boxes/boost_box.cpp b/Telegram/SourceFiles/ui/boxes/boost_box.cpp index 691d84f16c78c..bb99e43a8690e 100644 --- a/Telegram/SourceFiles/ui/boxes/boost_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/boost_box.cpp @@ -175,7 +175,7 @@ void AddFeaturesList( st::boostFeatureIconPosition); }; const auto proj = &Ui::Text::RichLangValue; - const auto max = std::max({ + const auto lowMax = std::max({ features.linkLogoLevel, features.transcribeLevel, features.emojiPackLevel, @@ -189,9 +189,13 @@ void AddFeaturesList( ? 0 : features.linkStylesByLevel.back().first), }); + const auto highMax = std::max(lowMax, features.sponsoredLevel); auto nameColors = 0; auto linkStyles = 0; - for (auto i = std::max(startFromLevel, 1); i <= max; ++i) { + for (auto i = std::max(startFromLevel, 1); i <= highMax; ++i) { + if ((i > lowMax) && (i < highMax)) { + continue; + } const auto unlocks = (i == startFromLevel); container->add( MakeFeaturesBadge( @@ -202,6 +206,9 @@ void AddFeaturesList( lt_count, rpl::single(float64(i)))), st::boostLevelBadgePadding); + if (i >= features.sponsoredLevel) { + add(tr::lng_channel_earn_off(proj), st::boostFeatureOffSponsored); + } if (i >= features.customWallpaperLevel) { add( (group diff --git a/Telegram/SourceFiles/ui/boxes/boost_box.h b/Telegram/SourceFiles/ui/boxes/boost_box.h index ecac121b9c3c3..6c129512deb71 100644 --- a/Telegram/SourceFiles/ui/boxes/boost_box.h +++ b/Telegram/SourceFiles/ui/boxes/boost_box.h @@ -40,6 +40,7 @@ struct BoostFeatures { int wallpaperLevel = 0; int wallpapersCount = 0; int customWallpaperLevel = 0; + int sponsoredLevel = 0; }; struct BoostBoxData { diff --git a/Telegram/SourceFiles/ui/effects/premium.style b/Telegram/SourceFiles/ui/effects/premium.style index afdac71466323..33fae62ebd5c2 100644 --- a/Telegram/SourceFiles/ui/effects/premium.style +++ b/Telegram/SourceFiles/ui/effects/premium.style @@ -364,3 +364,4 @@ boostFeatureLink: icon{{ "settings/premium/features/feature_links", windowBgActi boostFeatureName: icon{{ "settings/premium/features/feature_color_names", windowBgActive }}; boostFeatureStories: icon{{ "settings/premium/features/feature_stories", windowBgActive }}; boostFeatureTranscribe: icon{{ "settings/premium/features/feature_voice", windowBgActive }}; +boostFeatureOffSponsored: icon{{ "settings/premium/features/feature_off_sponsored", windowBgActive }}; From b648548001866158420cda364f61c19dd86752b4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jul 2024 08:57:41 +0400 Subject: [PATCH 13/36] Don't insert "data:image.." after image paste cancel. --- Telegram/SourceFiles/history/history_widget.cpp | 2 +- .../history/view/controls/history_view_compose_controls.cpp | 2 +- Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp | 4 ++++ Telegram/SourceFiles/ui/chat/attach/attach_prepare.h | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index fe0610dafea28..0a3c5a0647d34 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5668,7 +5668,7 @@ bool HistoryWidget::confirmSendingFiles( cursor.setPosition(position, QTextCursor::KeepAnchor); } _field->setTextCursor(cursor); - if (!insertTextOnCancel.isEmpty()) { + if (Ui::InsertTextOnImageCancel(insertTextOnCancel)) { _field->textCursor().insertText(insertTextOnCancel); } })); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index 779f0386b1b78..09aa2178eeb64 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -3415,7 +3415,7 @@ Fn ComposeControls::restoreTextCallback( cursor.setPosition(position, QTextCursor::KeepAnchor); } _field->setTextCursor(cursor); - if (!insertTextOnCancel.isEmpty()) { + if (Ui::InsertTextOnImageCancel(insertTextOnCancel)) { _field->textCursor().insertText(insertTextOnCancel); } }); diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp index e3f90912f41bb..505fa455bd20c 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.cpp @@ -82,6 +82,10 @@ bool CanBeInAlbumType(PreparedFile::Type type, AlbumType album) { Unexpected("AlbumType in CanBeInAlbumType."); } +bool InsertTextOnImageCancel(const QString &text) { + return !text.isEmpty() && !text.startsWith(u"data:image"_q); +} + PreparedList PreparedList::Reordered( PreparedList &&list, std::vector order) { diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h index 49fd71fa11d31..c1fb3a379312d 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_prepare.h @@ -88,6 +88,7 @@ struct PreparedFile { }; [[nodiscard]] bool CanBeInAlbumType(PreparedFile::Type type, AlbumType album); +[[nodiscard]] bool InsertTextOnImageCancel(const QString &text); struct PreparedList { enum class Error { From 8c97e915ec8580491485605ea19ab24ec7a7bcfa Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jul 2024 09:06:17 +0400 Subject: [PATCH 14/36] Create .mm source blanks for macOS modules. --- Telegram/create.bat | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Telegram/create.bat b/Telegram/create.bat index 85ec9439b1bf2..2307b0d2a1e83 100644 --- a/Telegram/create.bat +++ b/Telegram/create.bat @@ -67,26 +67,30 @@ exit /b %errorlevel% set "CommandPath=%1" set "CommandPathUnix=!CommandPath:\=/!" set "CommandPathWin=!CommandPath:/=\!" - + if "!CommandPathUnix:~-4!" == "_mac" ( + set "CommandExt=mm" + ) else ( + set "CommandExt=cpp" + ) if "!CommandPathUnix!" == "" ( echo Provide source path. exit /b 1 - ) else if exist "SourceFiles\!CommandPathWin!.cpp" ( + ) else if exist "SourceFiles\!CommandPathWin!.!CommandExt!" ( echo This source already exists. exit /b 1 ) - echo Generating source !CommandPathUnix!.cpp.. - mkdir "SourceFiles\!CommandPathWin!.cpp" - rmdir "SourceFiles\!CommandPathWin!.cpp" + echo Generating source !CommandPathUnix!.!CommandExt!.. + mkdir "SourceFiles\!CommandPathWin!.!CommandExt!" + rmdir "SourceFiles\!CommandPathWin!.!CommandExt!" - call :write_comment !CommandPathWin!.cpp + call :write_comment !CommandPathWin!.!CommandExt! set "quote=""" set "quote=!quote:~0,1!" set "source1=#include !quote!!CommandPathUnix!.h!quote!" ( echo !source1! echo. - )>> "SourceFiles\!CommandPathWin!.cpp" + )>> "SourceFiles\!CommandPathWin!.!CommandExt!" exit /b ) From 219671a3bcd73cd5859fbc174eaa09abe082a3fd Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 4 Jul 2024 12:01:59 +0400 Subject: [PATCH 15/36] Fix archive in Main Menu context menu. --- Telegram/SourceFiles/window/window_peer_menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index bce7a9ab1a838..f8259eec76b9d 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1472,7 +1472,8 @@ void Filler::fillArchiveActions() { const auto controller = _controller; const auto hidden = controller->session().settings().archiveCollapsed(); - { + const auto inmenu = controller->session().settings().archiveInMainMenu(); + if (!inmenu) { const auto text = hidden ? tr::lng_context_archive_expand(tr::now) : tr::lng_context_archive_collapse(tr::now); @@ -1481,7 +1482,6 @@ void Filler::fillArchiveActions() { controller->session().saveSettingsDelayed(); }, hidden ? &st::menuIconExpand : &st::menuIconCollapse); } - const auto inmenu = controller->session().settings().archiveInMainMenu(); { const auto text = inmenu ? tr::lng_context_archive_to_list(tr::now) From 1028219276fc1d87fde9e9fd8dad9cb2af2180ed Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 10:52:44 +0400 Subject: [PATCH 16/36] Allow chats list preview for narrow photos. --- Telegram/SourceFiles/data/data_media_types.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index 15dfedecd1703..a7b2690eab0d2 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -121,8 +121,8 @@ struct AlbumCounts { ImageRoundRadius radius, bool spoiler) { const auto original = image->original(); - if (original.width() * 10 < original.height() - || original.height() * 10 < original.width()) { + if (original.width() * 20 < original.height() + || original.height() * 20 < original.width()) { return QImage(); } const auto factor = style::DevicePixelRatio(); From b6664625ea6b92fc12180225799ebe6fefc478bc Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 13:25:39 +0400 Subject: [PATCH 17/36] Fix assigning text after formatted text. Fixes #28115. --- Telegram/lib_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 067733899d62c..366fc9843562d 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 067733899d62caa5411f54904a431d3484fd02e3 +Subproject commit 366fc9843562da1628385e796a4d6f114f8057a7 From f20475f07edaf2394a3cba5ec7397284be897acf Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 13:30:39 +0400 Subject: [PATCH 18/36] Show forbidden icon on disabled webview button. --- Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 5e9dde92e8648..569c61bb93b9f 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -178,6 +178,8 @@ void Panel::Button::updateFg(QColor fg) { void Panel::Button::updateArgs(MainButtonArgs &&args) { _textFull = std::move(args.text); setDisabled(!args.isActive); + setPointerCursor(false); + setCursor(args.isActive ? style::cur_pointer : Qt::ForbiddenCursor); setVisible(args.isVisible); toggleProgress(args.isProgressVisible); update(); From df277b366b13d41e180168529a5385dfde1a02a4 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 13:30:58 +0400 Subject: [PATCH 19/36] Fix build on Windows. --- Telegram/SourceFiles/_other/updater_win.cpp | 4 ++-- Telegram/ThirdParty/libtgvoip | 2 +- Telegram/lib_webrtc | 2 +- Telegram/lib_webview | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/_other/updater_win.cpp b/Telegram/SourceFiles/_other/updater_win.cpp index 0b9b247853279..e779c8f20fcfe 100644 --- a/Telegram/SourceFiles/_other/updater_win.cpp +++ b/Telegram/SourceFiles/_other/updater_win.cpp @@ -571,8 +571,8 @@ void _generateDump(EXCEPTION_POINTERS* pExceptionPointers) { } if (!hDumpFile || hDumpFile == INVALID_HANDLE_VALUE) { WCHAR wstrPath[maxFileLen]; - DWORD wstrPathLen; - if (wstrPathLen = GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen)) { + DWORD wstrPathLen = GetEnvironmentVariable(L"APPDATA", wstrPath, maxFileLen); + if (wstrPathLen) { wsprintf(wstrPath + wstrPathLen, L"\\%s\\", _programName); hDumpFile = _generateDumpFileAtPath(wstrPath); } diff --git a/Telegram/ThirdParty/libtgvoip b/Telegram/ThirdParty/libtgvoip index 25facad342c32..2d2592860478e 160000 --- a/Telegram/ThirdParty/libtgvoip +++ b/Telegram/ThirdParty/libtgvoip @@ -1 +1 @@ -Subproject commit 25facad342c3280315f9ef553906f46c3eeba1e4 +Subproject commit 2d2592860478e60d972b96e67ee034b8a71bb57a diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index f701713cd798b..eb94965403569 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit f701713cd798bd7d5f69d318fdefb125d101aa76 +Subproject commit eb9496540356945e2c9fb700bcfa51444fd36f41 diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 659b9181240aa..363db4e49a0b7 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 659b9181240aae16c05ef8ab7e6c4dd527afcf8a +Subproject commit 363db4e49a0b78e5dd08bd922e09cf8810318c09 From 149c69c9f5deb5577fb44394796ed15774024b73 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 22:13:13 +0400 Subject: [PATCH 20/36] Use a separate string for Your Stars in Settings. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/settings/settings_main.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index db9afbe0e073c..ea754fcf9476c 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1115,6 +1115,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_settings_faq" = "Telegram FAQ"; "lng_settings_faq_link" = "https://telegram.org/faq#general-questions"; "lng_settings_features" = "Telegram Features"; +"lng_settings_credits" = "Your Stars"; "lng_settings_logout" = "Log Out"; "lng_sure_logout" = "Are you sure you want to log out?"; diff --git a/Telegram/SourceFiles/settings/settings_main.cpp b/Telegram/SourceFiles/settings/settings_main.cpp index d08ce9a11c09c..363ad342f3f91 100644 --- a/Telegram/SourceFiles/settings/settings_main.cpp +++ b/Telegram/SourceFiles/settings/settings_main.cpp @@ -503,7 +503,7 @@ void SetupPremium( AddPremiumStar( AddButtonWithLabel( wrap->entity(), - tr::lng_credits_summary_title(), + tr::lng_settings_credits(), controller->session().creditsValue( ) | rpl::map([=](uint64 c) { return c ? Lang::FormatCountToShort(c).string : QString{}; From a01d48f0631a6cce547ce3137a15102edd8ddafb Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 22:21:04 +0400 Subject: [PATCH 21/36] Update submodules. --- Telegram/lib_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 366fc9843562d..96be2a6b72f04 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 366fc9843562da1628385e796a4d6f114f8057a7 +Subproject commit 96be2a6b72f0405a9c01407148303fba2dab101c From 78093173a92e9b0b60086ed5d91bdc051be7fb67 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 6 Jul 2024 22:25:44 +0400 Subject: [PATCH 22/36] Version 5.2.3. - Fix crash in bot star stats page. - Bug fixes and other minor improvements. --- Telegram/Resources/uwp/AppX/AppxManifest.xml | 2 +- Telegram/Resources/winrc/Telegram.rc | 8 ++++---- Telegram/Resources/winrc/Updater.rc | 8 ++++---- Telegram/SourceFiles/core/version.h | 4 ++-- Telegram/build/version | 8 ++++---- Telegram/lib_storage | 2 +- changelog.txt | 5 +++++ 7 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index 53203464b97ab..46918013d2ffb 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -10,7 +10,7 @@ + Version="5.2.3.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index 2d9446598cc8f..c47677eb21751 100644 --- a/Telegram/Resources/winrc/Telegram.rc +++ b/Telegram/Resources/winrc/Telegram.rc @@ -44,8 +44,8 @@ IDI_ICON1 ICON "..\\art\\icon256.ico" // VS_VERSION_INFO VERSIONINFO - FILEVERSION 5,2,2,0 - PRODUCTVERSION 5,2,2,0 + FILEVERSION 5,2,3,0 + PRODUCTVERSION 5,2,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "5.2.2.0" + VALUE "FileVersion", "5.2.3.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "5.2.2.0" + VALUE "ProductVersion", "5.2.3.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index abd5f4d0e0a06..5594959fe574c 100644 --- a/Telegram/Resources/winrc/Updater.rc +++ b/Telegram/Resources/winrc/Updater.rc @@ -35,8 +35,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION 5,2,2,0 - PRODUCTVERSION 5,2,2,0 + FILEVERSION 5,2,3,0 + PRODUCTVERSION 5,2,3,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -53,10 +53,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop Updater" - VALUE "FileVersion", "5.2.2.0" + VALUE "FileVersion", "5.2.3.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "5.2.2.0" + VALUE "ProductVersion", "5.2.3.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 57252c888c8ac..e1ac92bf4e671 100644 --- a/Telegram/SourceFiles/core/version.h +++ b/Telegram/SourceFiles/core/version.h @@ -22,7 +22,7 @@ constexpr auto AppId = "{53F49750-6209-4FBF-9CA8-7A333C87D1ED}"_cs; constexpr auto AppNameOld = "Telegram Win (Unofficial)"_cs; constexpr auto AppName = "Telegram Desktop"_cs; constexpr auto AppFile = "Telegram"_cs; -constexpr auto AppVersion = 5002002; -constexpr auto AppVersionStr = "5.2.2"; +constexpr auto AppVersion = 5002003; +constexpr auto AppVersionStr = "5.2.3"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index 5531916133f43..4d2b8605937ff 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 5002002 +AppVersion 5002003 AppVersionStrMajor 5.2 -AppVersionStrSmall 5.2.2 -AppVersionStr 5.2.2 +AppVersionStrSmall 5.2.3 +AppVersionStr 5.2.3 BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 5.2.2 +AppVersionOriginal 5.2.3 diff --git a/Telegram/lib_storage b/Telegram/lib_storage index 0971b69ca90f1..ccdc72548a506 160000 --- a/Telegram/lib_storage +++ b/Telegram/lib_storage @@ -1 +1 @@ -Subproject commit 0971b69ca90f1697ef81276d9820dcd6d26de4ac +Subproject commit ccdc72548a5065b5991b4e06e610d76bc4f6023e diff --git a/changelog.txt b/changelog.txt index 6e398bcc664f5..c0298f855afe6 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,8 @@ +5.2.3 (07.07.24) + +- Fix crash in bot star stats page. +- Bug fixes and other minor improvements. + 5.2.2 (02.07.24) - Fix topics search in topic groups. From 6effac7915e271e7762bd7997a1c858e67bb3e9e Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 9 Jul 2024 15:47:14 +0200 Subject: [PATCH 23/36] Migrate games to AttachWebView. --- Telegram/SourceFiles/api/api_bot.cpp | 6 +- Telegram/SourceFiles/boxes/share_box.cpp | 200 ++---------------- Telegram/SourceFiles/boxes/share_box.h | 12 +- .../SourceFiles/core/click_handler_types.cpp | 37 +++- .../SourceFiles/core/local_url_handlers.cpp | 19 -- .../view/history_view_context_menu.cpp | 11 +- .../history/view/history_view_context_menu.h | 4 + .../inline_bots/bot_attach_web_view.cpp | 81 +++++++ .../inline_bots/bot_attach_web_view.h | 15 +- .../ui/chat/attach/attach_bot_webview.cpp | 51 ++++- .../ui/chat/attach/attach_bot_webview.h | 10 + 11 files changed, 223 insertions(+), 223 deletions(-) diff --git a/Telegram/SourceFiles/api/api_bot.cpp b/Telegram/SourceFiles/api/api_bot.cpp index cf4611563ae0a..9290512611391 100644 --- a/Telegram/SourceFiles/api/api_bot.cpp +++ b/Telegram/SourceFiles/api/api_bot.cpp @@ -127,11 +127,7 @@ void SendBotCallbackData( UrlClickHandler::Open(link); return; } - const auto scoreLink = AppendShareGameScoreUrl( - session, - link, - item->fullId()); - BotGameUrlClickHandler(bot, scoreLink).onClick({ + BotGameUrlClickHandler(bot, link).onClick({ Qt::LeftButton, QVariant::fromValue(ClickHandlerContext{ .itemId = item->fullId(), diff --git a/Telegram/SourceFiles/boxes/share_box.cpp b/Telegram/SourceFiles/boxes/share_box.cpp index 043a8ad18650a..e7e3054aa4217 100644 --- a/Telegram/SourceFiles/boxes/share_box.cpp +++ b/Telegram/SourceFiles/boxes/share_box.cpp @@ -1409,55 +1409,6 @@ std::vector> ShareBox::Inner::selected() const { return result; } -QString AppendShareGameScoreUrl( - not_null session, - const QString &url, - const FullMsgId &fullId) { - auto shareHashData = QByteArray(0x20, Qt::Uninitialized); - auto shareHashDataInts = reinterpret_cast(shareHashData.data()); - const auto peer = fullId.peer - ? session->data().peerLoaded(fullId.peer) - : static_cast(nullptr); - const auto channelAccessHash = uint64((peer && peer->isChannel()) - ? peer->asChannel()->access - : 0); - shareHashDataInts[0] = session->userId().bare; - shareHashDataInts[1] = fullId.peer.value; - shareHashDataInts[2] = uint64(fullId.msg.bare); - shareHashDataInts[3] = channelAccessHash; - - // Count SHA1() of data. - auto key128Size = 0x10; - auto shareHashEncrypted = QByteArray(key128Size + shareHashData.size(), Qt::Uninitialized); - hashSha1(shareHashData.constData(), shareHashData.size(), shareHashEncrypted.data()); - - //// Mix in channel access hash to the first 64 bits of SHA1 of data. - //*reinterpret_cast(shareHashEncrypted.data()) ^= channelAccessHash; - - // Encrypt data. - if (!session->local().encrypt(shareHashData.constData(), shareHashEncrypted.data() + key128Size, shareHashData.size(), shareHashEncrypted.constData())) { - return url; - } - - auto shareHash = shareHashEncrypted.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - auto shareUrl = u"tg://share_game_score?hash="_q + QString::fromLatin1(shareHash); - - auto shareComponent = u"tgShareScoreUrl="_q + qthelp::url_encode(shareUrl); - - auto hashPosition = url.indexOf('#'); - if (hashPosition < 0) { - return url + '#' + shareComponent; - } - auto hash = url.mid(hashPosition + 1); - if (hash.indexOf('=') >= 0 || hash.indexOf('?') >= 0) { - return url + '&' + shareComponent; - } - if (!hash.isEmpty()) { - return url + '?' + shareComponent; - } - return url + shareComponent; -} - ChatHelpers::ForwardedMessagePhraseArgs CreateForwardedMessagePhraseArgs( const std::vector> &result, const MessageIdsList &msgIds) { @@ -1612,9 +1563,8 @@ ShareBox::SubmitCallback ShareBox::DefaultForwardCallback( } void FastShareMessage( - not_null controller, + std::shared_ptr show, not_null item) { - const auto show = controller->uiShow(); const auto history = item->history(); const auto owner = &history->owner(); const auto session = &history->session(); @@ -1643,7 +1593,7 @@ void FastShareMessage( } if (item->hasDirectLink()) { using namespace HistoryView; - CopyPostLink(controller, item->fullId(), Context::History); + CopyPostLink(show, item->fullId(), Context::History); } else if (const auto bot = item->getMessageBot()) { if (const auto media = item->media()) { if (const auto game = media->game()) { @@ -1675,23 +1625,27 @@ void FastShareMessage( auto copyLinkCallback = canCopyLink ? Fn(std::move(copyCallback)) : Fn(); - controller->show( - Box(ShareBox::Descriptor{ - .session = session, - .copyCallback = std::move(copyLinkCallback), - .submitCallback = ShareBox::DefaultForwardCallback( - show, - history, - msgIds), - .filterCallback = std::move(filterCallback), - .forwardOptions = { - .sendersCount = ItemsForwardSendersCount(items), - .captionsCount = ItemsForwardCaptionsCount(items), - .show = !hasOnlyForcedForwardedInfo, - }, - .premiumRequiredError = SharePremiumRequiredError(), - }), - Ui::LayerOption::CloseOther); + show->show(Box(ShareBox::Descriptor{ + .session = session, + .copyCallback = std::move(copyLinkCallback), + .submitCallback = ShareBox::DefaultForwardCallback( + show, + history, + msgIds), + .filterCallback = std::move(filterCallback), + .forwardOptions = { + .sendersCount = ItemsForwardSendersCount(items), + .captionsCount = ItemsForwardCaptionsCount(items), + .show = !hasOnlyForcedForwardedInfo, + }, + .premiumRequiredError = SharePremiumRequiredError(), + }), Ui::LayerOption::CloseOther); +} + +void FastShareMessage( + not_null controller, + not_null item) { + FastShareMessage(controller->uiShow(), item); } void FastShareLink( @@ -1793,111 +1747,3 @@ auto SharePremiumRequiredError() -> Fn)> { return WritePremiumRequiredError; } - -void ShareGameScoreByHash( - not_null controller, - const QString &hash) { - auto &session = controller->session(); - auto key128Size = 0x10; - - auto hashEncrypted = QByteArray::fromBase64(hash.toLatin1(), QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals); - if (hashEncrypted.size() <= key128Size || (hashEncrypted.size() != key128Size + 0x20)) { - controller->show( - Ui::MakeInformBox(tr::lng_confirm_phone_link_invalid()), - Ui::LayerOption::CloseOther); - return; - } - - // Decrypt data. - auto hashData = QByteArray(hashEncrypted.size() - key128Size, Qt::Uninitialized); - if (!session.local().decrypt(hashEncrypted.constData() + key128Size, hashData.data(), hashEncrypted.size() - key128Size, hashEncrypted.constData())) { - return; - } - - // Count SHA1() of data. - char dataSha1[20] = { 0 }; - hashSha1(hashData.constData(), hashData.size(), dataSha1); - - //// Mix out channel access hash from the first 64 bits of SHA1 of data. - //auto channelAccessHash = *reinterpret_cast(hashEncrypted.data()) ^ *reinterpret_cast(dataSha1); - - //// Check next 64 bits of SHA1() of data. - //auto skipSha1Part = sizeof(channelAccessHash); - //if (memcmp(dataSha1 + skipSha1Part, hashEncrypted.constData() + skipSha1Part, key128Size - skipSha1Part) != 0) { - // Ui::show(Box(tr::lng_share_wrong_user(tr::now))); - // return; - //} - - // Check 128 bits of SHA1() of data. - if (memcmp(dataSha1, hashEncrypted.constData(), key128Size) != 0) { - controller->show( - Ui::MakeInformBox(tr::lng_share_wrong_user()), - Ui::LayerOption::CloseOther); - return; - } - - auto hashDataInts = reinterpret_cast(hashData.data()); - if (hashDataInts[0] != session.userId().bare) { - controller->show( - Ui::MakeInformBox(tr::lng_share_wrong_user()), - Ui::LayerOption::CloseOther); - return; - } - - const auto peerId = PeerId(hashDataInts[1]); - const auto channelAccessHash = hashDataInts[3]; - if (!peerIsChannel(peerId) && channelAccessHash) { - // If there is no channel id, there should be no channel access_hash. - controller->show( - Ui::MakeInformBox(tr::lng_share_wrong_user()), - Ui::LayerOption::CloseOther); - return; - } - - const auto msgId = MsgId(int64(hashDataInts[2])); - if (const auto item = session.data().message(peerId, msgId)) { - FastShareMessage(controller, item); - } else { - const auto weak = base::make_weak(controller); - const auto resolveMessageAndShareScore = crl::guard(weak, [=]( - PeerData *peer) { - auto done = crl::guard(weak, [=] { - const auto item = weak->session().data().message( - peerId, - msgId); - if (item) { - FastShareMessage(weak.get(), item); - } else { - weak->show( - Ui::MakeInformBox(tr::lng_edit_deleted()), - Ui::LayerOption::CloseOther); - } - }); - auto &api = weak->session().api(); - api.requestMessageData(peer, msgId, std::move(done)); - }); - - const auto peer = peerIsChannel(peerId) - ? controller->session().data().peerLoaded(peerId) - : nullptr; - if (peer || !peerIsChannel(peerId)) { - resolveMessageAndShareScore(peer); - } else { - const auto owner = &controller->session().data(); - controller->session().api().request(MTPchannels_GetChannels( - MTP_vector( - 1, - MTP_inputChannel( - MTP_long(peerToChannel(peerId).bare), - MTP_long(channelAccessHash))) - )).done([=](const MTPmessages_Chats &result) { - result.match([&](const auto &data) { - owner->processChats(data.vchats()); - }); - if (const auto peer = owner->peerLoaded(peerId)) { - resolveMessageAndShareScore(peer); - } - }).send(); - } - } -} diff --git a/Telegram/SourceFiles/boxes/share_box.h b/Telegram/SourceFiles/boxes/share_box.h index 32e824b15cff4..d0bf28ce91e2c 100644 --- a/Telegram/SourceFiles/boxes/share_box.h +++ b/Telegram/SourceFiles/boxes/share_box.h @@ -59,13 +59,11 @@ class SlideWrap; class PopupMenu; } // namespace Ui -QString AppendShareGameScoreUrl( - not_null session, - const QString &url, - const FullMsgId &fullId); -void ShareGameScoreByHash( - not_null controller, - const QString &hash); +class ShareBox; + +void FastShareMessage( + std::shared_ptr show, + not_null item); void FastShareMessage( not_null controller, not_null item); diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index 9b03e0b7430b7..eadb16181e122 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -20,6 +20,8 @@ For license and copyright information please follow this link: #include "history/history.h" #include "history/view/history_view_element.h" #include "history/history_item.h" +#include "inline_bots/bot_attach_web_view.h" +#include "data/data_game.h" #include "data/data_user.h" #include "data/data_session.h" #include "window/window_controller.h" @@ -171,23 +173,40 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const { if (Core::InternalPassportLink(url)) { return; } - - const auto open = [=] { + const auto openLink = [=] { UrlClickHandler::Open(url, context.other); }; - if (url.startsWith(u"tg://"_q, Qt::CaseInsensitive)) { - open(); - } else if (!_bot - || _bot->isVerified() + const auto my = context.other.value(); + const auto weakController = my.sessionWindow; + const auto controller = weakController.get(); + const auto item = controller + ? controller->session().data().message(my.itemId) + : nullptr; + const auto media = item ? item->media() : nullptr; + const auto game = media ? media->game() : nullptr; + if (url.startsWith(u"tg://"_q, Qt::CaseInsensitive) || !_bot || !game) { + openLink(); + } + const auto bot = _bot; + const auto title = game->title; + const auto itemId = my.itemId; + const auto openGame = [=] { + bot->session().attachWebView().showGame({ + .bot = bot, + .context = itemId, + .url = url, + .title = title, + }); + }; + if (_bot->isVerified() || _bot->session().local().isBotTrustedOpenGame(_bot->id)) { - open(); + openGame(); } else { - const auto my = context.other.value(); if (const auto controller = my.sessionWindow.get()) { const auto callback = [=, bot = _bot](Fn close) { close(); bot->session().local().markBotTrustedOpenGame(bot->id); - open(); + openGame(); }; controller->show(Ui::MakeConfirmBox({ .text = tr::lng_allow_bot_pass( diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 03c3254ab076d..9f4860da364d6 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -327,21 +327,6 @@ bool ConfirmPhone( return true; } -bool ShareGameScore( - Window::SessionController *controller, - const Match &match, - const QVariant &context) { - if (!controller) { - return false; - } - const auto params = url_parse_params( - match->captured(1), - qthelp::UrlParamNameTransform::ToLower); - ShareGameScoreByHash(controller, params.value(u"hash"_q)); - controller->window().activate(); - return true; -} - bool ApplySocksProxy( Window::SessionController *controller, const Match &match, @@ -1230,10 +1215,6 @@ const std::vector &LocalUrlHandlers() { u"^confirmphone/?\\?(.+)(#|$)"_q, ConfirmPhone }, - { - u"^share_game_score/?\\?(.+)(#|$)"_q, - ShareGameScore - }, { u"^socks/?\\?(.+)(#|$)"_q, ApplySocksProxy diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp index a53ab20284877..49013f1c85cb2 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.cpp +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.cpp @@ -1284,7 +1284,14 @@ void CopyPostLink( not_null controller, FullMsgId itemId, Context context) { - const auto item = controller->session().data().message(itemId); + CopyPostLink(controller->uiShow(), itemId, context); +} + +void CopyPostLink( + std::shared_ptr show, + FullMsgId itemId, + Context context) { + const auto item = show->session().data().message(itemId); if (!item || !item->hasDirectLink()) { return; } @@ -1311,7 +1318,7 @@ void CopyPostLink( return channel->hasUsername(); }(); - controller->showToast(isPublicLink + show->showToast(isPublicLink ? tr::lng_channel_public_link_copied(tr::now) : tr::lng_context_about_private_link(tr::now)); } diff --git a/Telegram/SourceFiles/history/view/history_view_context_menu.h b/Telegram/SourceFiles/history/view/history_view_context_menu.h index 8f00f4da80345..efb2a5fdd3ca9 100644 --- a/Telegram/SourceFiles/history/view/history_view_context_menu.h +++ b/Telegram/SourceFiles/history/view/history_view_context_menu.h @@ -61,6 +61,10 @@ void CopyPostLink( not_null controller, FullMsgId itemId, Context context); +void CopyPostLink( + std::shared_ptr show, + FullMsgId itemId, + Context context); void CopyStoryLink( std::shared_ptr show, FullStoryId storyId); diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index eb938ed2630de..ff263701120dc 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -10,6 +10,7 @@ For license and copyright information please follow this link: #include "api/api_blocked_peers.h" #include "api/api_common.h" #include "base/qthelp_url.h" +#include "boxes/share_box.h" #include "core/click_handler_types.h" #include "data/data_bot_app.h" #include "data/data_changes.h" @@ -802,6 +803,16 @@ void AttachWebView::botInvokeCustomMethod( }).send(); } +void AttachWebView::botShareGameScore() { + if (!_panel || !_gameContext) { + return; + } else if (const auto item = _session->data().message(_gameContext)) { + FastShareMessage(uiShow(), item); + } else { + _panel->showToast({ tr::lng_message_not_found(tr::now) }); + } +} + void AttachWebView::botClose() { crl::on_main(this, [=] { cancel(); }); } @@ -1547,6 +1558,7 @@ void AttachWebView::show( _lastShownUrl = url; _lastShownQueryId = queryId; _lastShownButtonText = buttonText; + _gameContext = {}; base::take(_panel); _catchingCancelInShowCall = true; _panel = Ui::BotWebView::Show({ @@ -1562,6 +1574,24 @@ void AttachWebView::show( started(queryId); } +void AttachWebView::showGame(ShowGameParams &¶ms) { + ActiveWebViews().emplace(this); + + base::take(_panel); + _gameContext = params.context; + + _catchingCancelInShowCall = true; + _panel = Ui::BotWebView::Show({ + .url = params.url, + .storageId = _session->local().resolveStorageIdBots(), + .title = rpl::single(params.title), + .bottom = rpl::single('@' + params.bot->username()), + .delegate = static_cast(this), + .menuButtons = Ui::BotWebView::MenuButton::ShareGame, + }); + _catchingCancelInShowCall = false; +} + void AttachWebView::started(uint64 queryId) { Expects(_bot != nullptr); Expects(_context != nullptr); @@ -1601,6 +1631,57 @@ void AttachWebView::started(uint64 queryId) { }, _panel->lifetime()); } +std::shared_ptr AttachWebView::uiShow() { + class Show final : public Main::SessionShow { + public: + explicit Show(not_null that) : _that(that) { + } + + void showOrHideBoxOrLayer( + std::variant< + v::null_t, + object_ptr, + std::unique_ptr> &&layer, + Ui::LayerOptions options, + anim::type animated) const override { + using UniqueLayer = std::unique_ptr; + using ObjectBox = object_ptr; + const auto panel = _that ? _that->_panel.get() : nullptr; + if (auto layerWidget = std::get_if(&layer)) { + Unexpected("Layers in AttachWebView are not implemented."); + } else if (auto box = std::get_if(&layer)) { + if (panel) { + panel->showBox(std::move(*box), options, animated); + } + } else if (panel) { + panel->hideLayer(animated); + } + } + [[nodiscard]] not_null toastParent() const override { + const auto panel = _that ? _that->_panel.get() : nullptr; + + Ensures(panel != nullptr); + return panel->toastParent(); + } + [[nodiscard]] bool valid() const override { + return _that && (_that->_panel != nullptr); + } + operator bool() const override { + return valid(); + } + + [[nodiscard]] Main::Session &session() const override { + Expects(_that.get() != nullptr); + return *_that->_session; + } + + private: + const base::weak_ptr _that; + + }; + return std::make_shared(this); +} + void AttachWebView::showToast( const QString &text, Window::SessionController *controller) { diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h index 0f8cb6e13c58b..87648b07e88b7 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.h @@ -29,6 +29,7 @@ class Panel; namespace Main { class Session; +class SessionShow; } // namespace Main namespace Window { @@ -155,12 +156,21 @@ class AttachWebView final [[nodiscard]] std::optional lookupLastAction( const QString &url) const; + struct ShowGameParams { + not_null bot; + FullMsgId context; + QString url; + QString title; + }; + void showGame(ShowGameParams &¶ms); + + [[nodiscard]] std::shared_ptr uiShow(); + static void ClearAll(); private: struct Context; - Webview::ThemeParams botThemeParams() override; bool botHandleLocalUri(QString uri, bool keepOpen) override; void botHandleInvoice(QString slug) override; @@ -176,6 +186,7 @@ class AttachWebView final void botSharePhone(Fn callback) override; void botInvokeCustomMethod( Ui::BotWebView::CustomMethodRequest request) override; + void botShareGameScore() override; void botClose() override; [[nodiscard]] static Context LookupContext( @@ -271,6 +282,8 @@ class AttachWebView final rpl::event_stream<> _attachBotsUpdates; base::flat_set> _disclaimerAccepted; + FullMsgId _gameContext; + std::unique_ptr _panel; bool _catchingCancelInShowCall = false; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp index 569c61bb93b9f..d367e3382e2ef 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.cpp @@ -25,6 +25,7 @@ For license and copyright information please follow this link: #include "webview/webview_interface.h" #include "base/debug_log.h" #include "base/invoke_queued.h" +#include "base/qt_signal_producer.h" #include "styles/style_payments.h" #include "styles/style_layers.h" #include "styles/style_menu_icons.h" @@ -34,6 +35,7 @@ For license and copyright information please follow this link: #include #include #include +#include namespace Ui::BotWebView { namespace { @@ -373,6 +375,13 @@ Panel::~Panel() { void Panel::requestActivate() { _widget->showAndActivate(); + if (const auto widget = _webview ? _webview->window.widget() : nullptr) { + InvokeQueued(widget, [=] { + if (widget->isVisible()) { + _webview->window.focus(); + } + }); + } } void Panel::toggleProgress(bool shown) { @@ -527,9 +536,15 @@ bool Panel::showWebview( _webview->window.navigate(url); } }, &st::menuIconRestore); - callback(tr::lng_bot_terms(tr::now), [=] { - File::OpenUrl(tr::lng_mini_apps_tos_url(tr::now)); - }, &st::menuIconGroupLog); + if (_menuButtons & MenuButton::ShareGame) { + callback(tr::lng_iv_share(tr::now), [=] { + _delegate->botShareGameScore(); + }, &st::menuIconShare); + } else { + callback(tr::lng_bot_terms(tr::now), [=] { + File::OpenUrl(tr::lng_mini_apps_tos_url(tr::now)); + }, &st::menuIconGroupLog); + } const auto main = (_menuButtons & MenuButton::RemoveFromMainMenu); if (main || (_menuButtons & MenuButton::RemoveFromMenu)) { const auto handler = [=] { @@ -691,6 +706,8 @@ bool Panel::createWebview(const Webview::ThemeParams ¶ms) { requestClipboardText(arguments); } else if (command == "web_app_set_header_color") { processHeaderColor(arguments); + } else if (command == "share_score") { + _delegate->botShareGameScore(); } }); @@ -722,6 +739,17 @@ postEvent: function(eventType, eventData) { setupProgressGeometry(); + base::qt_signal_producer( + _widget->window()->windowHandle(), + &QWindow::activeChanged + ) | rpl::filter([=] { + return _webview && _widget->window()->windowHandle()->isActive(); + }) | rpl::start_with_next([=] { + if (_webview && !_webview->window.widget()->isHidden()) { + _webview->window.focus(); + } + }, _webview->lifetime); + return true; } @@ -1207,6 +1235,13 @@ void Panel::updateFooterHeight() { } void Panel::showBox(object_ptr box) { + showBox(std::move(box), LayerOption::KeepOther, anim::type::normal); +} + +void Panel::showBox( + object_ptr box, + LayerOptions options, + anim::type animated) { if (const auto widget = _webview ? _webview->window.widget() : nullptr) { const auto hideNow = !widget->isHidden(); if (hideNow || _webview->lastHidingBox) { @@ -1220,10 +1255,12 @@ void Panel::showBox(object_ptr box) { && widget->isHidden() && _webview->lastHidingBox == raw) { widget->show(); + _webviewBottom->show(); } }, _webview->lifetime); if (hideNow) { widget->hide(); + _webviewBottom->hide(); } } } @@ -1237,6 +1274,14 @@ void Panel::showToast(TextWithEntities &&text) { _widget->showToast(std::move(text)); } +not_null Panel::toastParent() const { + return _widget->uiShow()->toastParent(); +} + +void Panel::hideLayer(anim::type animated) { + _widget->hideLayer(animated); +} + void Panel::showCriticalError(const TextWithEntities &text) { _progress = nullptr; _webviewProgress = false; diff --git a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h index 91e4232793875..d9071c846e50e 100644 --- a/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h +++ b/Telegram/SourceFiles/ui/chat/attach/attach_bot_webview.h @@ -20,6 +20,8 @@ namespace Ui { class BoxContent; class RpWidget; class SeparatePanel; +enum class LayerOption; +using LayerOptions = base::flags; } // namespace Ui namespace Webview { @@ -40,6 +42,7 @@ enum class MenuButton { OpenBot = 0x01, RemoveFromMenu = 0x02, RemoveFromMainMenu = 0x04, + ShareGame = 0x08, }; inline constexpr bool is_flag_type(MenuButton) { return true; } using MenuButtons = base::flags; @@ -67,6 +70,7 @@ class Delegate { virtual void botAllowWriteAccess(Fn callback) = 0; virtual void botSharePhone(Fn callback) = 0; virtual void botInvokeCustomMethod(CustomMethodRequest request) = 0; + virtual void botShareGameScore() = 0; virtual void botClose() = 0; }; @@ -89,7 +93,13 @@ class Panel final : public base::has_weak_ptr { rpl::producer bottomText); void showBox(object_ptr box); + void showBox( + object_ptr box, + LayerOptions options, + anim::type animated); + void hideLayer(anim::type animated); void showToast(TextWithEntities &&text); + not_null toastParent() const; void showCriticalError(const TextWithEntities &text); void showWebviewError( const QString &text, From 94ad8f9bc38d2225601c9eb9529c75f789acc7e9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 9 Jul 2024 16:59:56 +0200 Subject: [PATCH 24/36] Don't register collapsed row click as userpic. Fixes #28149. --- Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index cb33e8a9a2916..6e60f072dfc73 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -3814,7 +3814,9 @@ ChosenRow InnerWidget::computeChosenRow() const { bool InnerWidget::isUserpicPress() const { return (_lastRowLocalMouseX >= 0) - && (_lastRowLocalMouseX < _st->nameLeft); + && (_lastRowLocalMouseX < _st->nameLeft) + && (_collapsedSelected < 0 + || _collapsedSelected >= _collapsedRows.size()); } bool InnerWidget::isUserpicPressOnWide() const { From ebba58217c08decc97b6bc85cc7847bb16b122d6 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 9 Jul 2024 17:00:24 +0200 Subject: [PATCH 25/36] Don't set focus to shown third section. I hope it fixes #28142. --- Telegram/SourceFiles/window/section_widget.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/window/section_widget.cpp b/Telegram/SourceFiles/window/section_widget.cpp index ae24ad4d3e3a2..4ec94b0ab71d5 100644 --- a/Telegram/SourceFiles/window/section_widget.cpp +++ b/Telegram/SourceFiles/window/section_widget.cpp @@ -8,6 +8,7 @@ For license and copyright information please follow this link: #include "window/section_widget.h" #include "mainwidget.h" +#include "mainwindow.h" #include "ui/ui_utility.h" #include "ui/chat/chat_theme.h" #include "ui/painter.h" @@ -456,7 +457,7 @@ void SectionWidget::showFinished() { showChildren(); showFinishedHook(); - setInnerFocus(); + controller()->widget()->setInnerFocus(); } rpl::producer SectionWidget::desiredHeight() const { From 46b69a938b6d0ed3ef2660d632c8c4c6a9934271 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 10 Jul 2024 11:41:18 +0200 Subject: [PATCH 26/36] Revert "Register tg:// scheme on initial launch." This reverts commit 8cbeadc68a88acb207305ad02e6c01df3a80b690. --- Telegram/SourceFiles/core/application.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/core/application.cpp b/Telegram/SourceFiles/core/application.cpp index e3e0de6c6e1a3..79dfd0977bcfc 100644 --- a/Telegram/SourceFiles/core/application.cpp +++ b/Telegram/SourceFiles/core/application.cpp @@ -270,14 +270,9 @@ void Application::run() { refreshGlobalProxy(); // Depends on app settings being read. - if (const auto old = Local::oldSettingsVersion()) { - if (old < AppVersion) { - autoRegisterUrlScheme(); - Platform::NewVersionLaunched(old); - } - } else { - // Initial launch. + if (const auto old = Local::oldSettingsVersion(); old < AppVersion) { autoRegisterUrlScheme(); + Platform::NewVersionLaunched(old); } if (cAutoStart() && !Platform::AutostartSupported()) { From f7d698b9ff05aaa829d119e4c38d485e01a53259 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 11 Jul 2024 14:23:34 +0200 Subject: [PATCH 27/36] Fix last seen within week/month. --- Telegram/SourceFiles/data/data_peer_values.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/data/data_peer_values.cpp b/Telegram/SourceFiles/data/data_peer_values.cpp index 60a1c5f43d15b..e4694f88d63e7 100644 --- a/Telegram/SourceFiles/data/data_peer_values.cpp +++ b/Telegram/SourceFiles/data/data_peer_values.cpp @@ -65,12 +65,14 @@ std::optional OnlineTextCommon(LastseenStatus status, TimeId now) { return tr::lng_status_online(tr::now); } else if (status.isLongAgo()) { return tr::lng_status_offline(tr::now); - } else if (status.isRecently() || status.isHidden()) { + } else if (status.isRecently()) { return tr::lng_status_recently(tr::now); } else if (status.isWithinWeek()) { return tr::lng_status_last_week(tr::now); } else if (status.isWithinMonth()) { return tr::lng_status_last_month(tr::now); + } else if (status.isHidden()) { + return tr::lng_status_recently(tr::now); } return std::nullopt; } From 03d4dd00d44d51440466c3b554e28f6018aaa903 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 12 Jul 2024 10:30:42 +0200 Subject: [PATCH 28/36] Delete selection on Ctrl+Backspace. Fixes #28143. --- Telegram/lib_ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 96be2a6b72f04..9b69f3855ac9f 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 96be2a6b72f0405a9c01407148303fba2dab101c +Subproject commit 9b69f3855ac9feb760aef92ce98e874129303d4d From 5b9278ecedbe990ba9e5e00dd8baf3248885991f Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 10 Jul 2024 17:51:45 +0400 Subject: [PATCH 29/36] Switch Docker to distro-provided cmake --- Telegram/build/docker/centos_env/Dockerfile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index 71c9533ebe736..e4f7d1fb11ce2 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -2,8 +2,6 @@ {%- set GIT_FREEDESKTOP = GIT ~ "/gitlab-freedesktop-mirrors" -%} {%- set QT = "6.7.2" -%} {%- set QT_TAG = "v" ~ QT -%} -{%- set CMAKE_VER = "3.27.6" -%} -{%- set CMAKE_FILE = "cmake-" ~ CMAKE_VER ~ "-Linux-x86_64.sh" -%} {%- set CFLAGS_DEBUG = "-g -pipe -fPIC -fstack-protector-all -fstack-clash-protection -fcf-protection -D_GLIBCXX_ASSERTIONS" -%} {%- set CFLAGS_LTO = "-flto=auto -ffat-lto-objects" -%} {%- set LibrariesPath = "/usr/src/Libraries" -%} @@ -18,7 +16,7 @@ ENV PKG_CONFIG_PATH /usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/loc RUN dnf -y install epel-release \ && dnf config-manager --set-enabled powertools \ - && dnf -y install autoconf automake libtool pkgconfig make patch git \ + && dnf -y install cmake autoconf automake libtool pkgconfig make patch git \ python3.11-pip python3.11-devel gperf flex bison clang lld nasm yasm \ file which perl-open perl-XML-Parser perl-IPC-Cmd xorg-x11-util-macros \ gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils \ @@ -34,12 +32,6 @@ WORKDIR {{ LibrariesPath }} RUN python3 -m pip install meson ninja -RUN mkdir /opt/cmake \ - && curl -sSLo {{ CMAKE_FILE }} {{ GIT }}/Kitware/CMake/releases/download/v{{ CMAKE_VER }}/{{ CMAKE_FILE }} \ - && sh {{ CMAKE_FILE }} --prefix=/opt/cmake --skip-license \ - && ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake \ - && rm {{ CMAKE_FILE }} - FROM builder-base AS builder ENV AR gcc-ar ENV RANLIB gcc-ranlib From c6e1cf639e16249ab811b153b8e956740403851a Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 12 Jul 2024 10:32:23 +0200 Subject: [PATCH 30/36] Update API scheme to layer 184. --- Telegram/Resources/langs/lang.strings | 1 + .../export/data/export_data_types.cpp | 7 ++++ .../export/data/export_data_types.h | 10 ++++- .../export/output/export_output_html.cpp | 6 +++ .../export/output/export_output_json.cpp | 7 ++++ Telegram/SourceFiles/history/history_item.cpp | 37 +++++++++++++++++++ .../history/history_item_components.h | 9 +++++ .../view/history_view_service_message.cpp | 2 + Telegram/SourceFiles/mtproto/scheme/api.tl | 5 ++- .../settings/settings_credits_graphics.cpp | 28 ++++++++++++++ .../settings/settings_credits_graphics.h | 3 ++ 11 files changed, 112 insertions(+), 3 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index ea754fcf9476c..0c60906ec3767 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1889,6 +1889,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_boost_apply#one" = "{from} boosted the group"; "lng_action_boost_apply#other" = "{from} boosted the group {count} times"; "lng_action_set_chat_intro" = "{from} added the message below for all empty chats. How?"; +"lng_action_payment_refunded" = "{peer} refunded back {amount}"; "lng_similar_channels_title" = "Similar channels"; "lng_similar_channels_view_all" = "View all"; diff --git a/Telegram/SourceFiles/export/data/export_data_types.cpp b/Telegram/SourceFiles/export/data/export_data_types.cpp index 16dbfb994aa2d..9e65eac39c604 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.cpp +++ b/Telegram/SourceFiles/export/data/export_data_types.cpp @@ -1515,6 +1515,13 @@ ServiceAction ParseServiceAction( result.content = content; }, [&](const MTPDmessageActionRequestedPeerSentMe &data) { // Should not be in user inbox. + }, [&](const MTPDmessageActionPaymentRefunded &data) { + auto content = ActionPaymentRefunded(); + content.currency = ParseString(data.vcurrency()); + content.amount = data.vtotal_amount().v; + content.peerId = ParsePeerId(data.vpeer()); + content.transactionId = data.vcharge().data().vid().v; + result.content = content; }, [](const MTPDmessageActionEmpty &data) {}); return result; } diff --git a/Telegram/SourceFiles/export/data/export_data_types.h b/Telegram/SourceFiles/export/data/export_data_types.h index cc16c47badfe2..72824a2eef781 100644 --- a/Telegram/SourceFiles/export/data/export_data_types.h +++ b/Telegram/SourceFiles/export/data/export_data_types.h @@ -576,6 +576,13 @@ struct ActionBoostApply { int boosts = 0; }; +struct ActionPaymentRefunded { + PeerId peerId = 0; + Utf8String currency; + uint64 amount = 0; + Utf8String transactionId; +}; + struct ServiceAction { std::variant< v::null_t, @@ -617,7 +624,8 @@ struct ServiceAction { ActionGiftCode, ActionGiveawayLaunch, ActionGiveawayResults, - ActionBoostApply> content; + ActionBoostApply, + ActionPaymentRefunded> content; }; ServiceAction ParseServiceAction( diff --git a/Telegram/SourceFiles/export/output/export_output_html.cpp b/Telegram/SourceFiles/export/output/export_output_html.cpp index f49776ede4f68..d988fc00c33b1 100644 --- a/Telegram/SourceFiles/export/output/export_output_html.cpp +++ b/Telegram/SourceFiles/export/output/export_output_html.cpp @@ -1315,6 +1315,12 @@ auto HtmlWriter::Wrap::pushMessage( + " boosted the group " + QByteArray::number(data.boosts) + (data.boosts > 1 ? " times" : " time"); + }, [&](const ActionPaymentRefunded &data) { + const auto amount = FormatMoneyAmount(data.amount, data.currency); + auto result = peers.wrapPeerName(data.peerId) + + " refunded back " + + amount; + return result; }, [](v::null_t) { return QByteArray(); }); if (!serviceText.isEmpty()) { diff --git a/Telegram/SourceFiles/export/output/export_output_json.cpp b/Telegram/SourceFiles/export/output/export_output_json.cpp index adbad2b7fbcf0..5d4c7e42dbb89 100644 --- a/Telegram/SourceFiles/export/output/export_output_json.cpp +++ b/Telegram/SourceFiles/export/output/export_output_json.cpp @@ -625,6 +625,13 @@ QByteArray SerializeMessage( pushActor(); pushAction("boost_apply"); push("boosts", data.boosts); + }, [&](const ActionPaymentRefunded &data) { + pushAction("refunded_payment"); + push("amount", data.amount); + push("currency", data.currency); + pushBare("peer_name", wrapPeerName(data.peerId)); + push("peer_id", data.peerId); + push("charge_id", data.transactionId); }, [](v::null_t) {}); if (v::is_null(message.action.content)) { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index d9c306013d330..d2386e7e62515 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -23,6 +23,7 @@ For license and copyright information please follow this link: #include "ui/text/format_values.h" #include "ui/text/text_isolated_emoji.h" #include "ui/text/text_utilities.h" +#include "settings/settings_credits_graphics.h" // ShowRefundInfoBox. #include "storage/file_upload.h" #include "storage/storage_shared_media.h" #include "main/main_account.h" @@ -4028,6 +4029,22 @@ void HistoryItem::createServiceFromMtp(const MTPDmessageService &message) { } } else if (type == mtpc_messageActionGiveawayResults) { UpdateComponents(HistoryServiceGiveawayResults::Bit()); + } else if (type == mtpc_messageActionPaymentRefunded) { + const auto &data = action.c_messageActionPaymentRefunded(); + UpdateComponents(HistoryServicePaymentRefund::Bit()); + const auto refund = Get(); + refund->peer = _history->owner().peer(peerFromMTP(data.vpeer())); + refund->amount = data.vtotal_amount().v; + refund->currency = qs(data.vcurrency()); + refund->transactionId = qs(data.vcharge().data().vid()); + const auto id = fullId(); + refund->link = std::make_shared([=]( + ClickContext context) { + const auto my = context.other.value(); + if (const auto window = my.sessionWindow.get()) { + Settings::ShowRefundInfoBox(window, id); + } + }); } if (const auto replyTo = message.vreply_to()) { replyTo->match([&](const MTPDmessageReplyHeader &data) { @@ -4941,6 +4958,25 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { return result; }; + auto preparePaymentRefunded = [&](const MTPDmessageActionPaymentRefunded &action) { + auto result = PreparedServiceText(); + const auto refund = Get(); + Assert(refund != nullptr); + Assert(refund->peer != nullptr); + + const auto amount = refund->amount; + const auto currency = refund->currency; + result.links.push_back(refund->peer->createOpenLink()); + result.text = tr::lng_action_payment_refunded( + tr::now, + lt_peer, + Ui::Text::Link(refund->peer->name(), 1), // Link 1. + lt_amount, + { Ui::FillAmountAndCurrency(amount, currency) }, + Ui::Text::WithEntities); + return result; + }; + setServiceText(action.match( prepareChatAddUserText, prepareChatJoinedByLink, @@ -4983,6 +5019,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { prepareGiveawayLaunch, prepareGiveawayResults, prepareBoostApply, + preparePaymentRefunded, PrepareEmptyText, PrepareErrorText)); diff --git a/Telegram/SourceFiles/history/history_item_components.h b/Telegram/SourceFiles/history/history_item_components.h index 8d262a52e3098..7e9fb6396bac2 100644 --- a/Telegram/SourceFiles/history/history_item_components.h +++ b/Telegram/SourceFiles/history/history_item_components.h @@ -671,6 +671,15 @@ struct HistoryServiceCustomLink ClickHandlerPtr link; }; +struct HistoryServicePaymentRefund +: public RuntimeComponent { + ClickHandlerPtr link; + PeerData *peer = nullptr; + QString transactionId; + QString currency; + uint64 amount = 0; +}; + enum class HistorySelfDestructType { Photo, Video, diff --git a/Telegram/SourceFiles/history/view/history_view_service_message.cpp b/Telegram/SourceFiles/history/view/history_view_service_message.cpp index 107bb9416051a..09fa2b43f3246 100644 --- a/Telegram/SourceFiles/history/view/history_view_service_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_service_message.cpp @@ -679,6 +679,8 @@ TextState Service::textState(QPoint point, StateRequest request) const { result.link = results->lnk; } else if (const auto custom = item->Get()) { result.link = custom->link; + } else if (const auto payment = item->Get()) { + result.link = payment->link; } else if (media && data()->showSimilarChannels()) { result = media->textState(mediaPoint, request); } diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 7b8700811d2a0..394a50efaf381 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -102,7 +102,7 @@ channel#aadfc8f flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5 channelForbidden#17d493d5 flags:# broadcast:flags.5?true megagroup:flags.8?true id:long access_hash:long title:string until_date:flags.16?int = Chat; chatFull#2633421b flags:# can_set_username:flags.7?true has_scheduled:flags.8?true translations_disabled:flags.19?true id:long about:string participants:ChatParticipants chat_photo:flags.2?Photo notify_settings:PeerNotifySettings exported_invite:flags.13?ExportedChatInvite bot_info:flags.3?Vector pinned_msg_id:flags.6?int folder_id:flags.11?int call:flags.12?InputGroupCall ttl_period:flags.14?int groupcall_default_join_as:flags.15?Peer theme_emoticon:flags.16?string requests_pending:flags.17?int recent_requesters:flags.17?Vector available_reactions:flags.18?ChatReactions reactions_limit:flags.20?int = ChatFull; -channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; +channelFull#bbab348d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet = ChatFull; chatParticipant#c02d4007 user_id:long inviter_id:long date:int = ChatParticipant; chatParticipantCreator#e46bcee4 user_id:long = ChatParticipant; @@ -179,6 +179,7 @@ messageActionGiveawayLaunch#332ba9ed = MessageAction; messageActionGiveawayResults#2a9fadc5 winners_count:int unclaimed_count:int = MessageAction; messageActionBoostApply#cc02aa6d boosts:int = MessageAction; messageActionRequestedPeerSentMe#93b31848 button_id:int peers:Vector = MessageAction; +messageActionPaymentRefunded#41b3e202 flags:# peer:Peer currency:string total_amount:long payload:flags.0?bytes charge:PaymentCharge = MessageAction; dialog#d58a08c6 flags:# pinned:flags.2?true unread_mark:flags.3?true view_forum_as_messages:flags.6?true peer:Peer top_message:int read_inbox_max_id:int read_outbox_max_id:int unread_count:int unread_mentions_count:int unread_reactions_count:int notify_settings:PeerNotifySettings pts:flags.0?int draft:flags.1?DraftMessage folder_id:flags.4?int ttl_period:flags.5?int = Dialog; dialogFolder#71bd134c flags:# pinned:flags.2?true folder:Folder peer:Peer top_message:int unread_muted_peers_count:int unread_unmuted_peers_count:int unread_muted_messages_count:int unread_unmuted_messages_count:int = Dialog; @@ -2493,4 +2494,4 @@ smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool; fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo; -// LAYER 183 +// LAYER 184 diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 648a6490031a2..3b88e8d484fb9 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -23,6 +23,7 @@ For license and copyright information please follow this link: #include "data/stickers/data_custom_emoji.h" #include "history/history.h" #include "history/history_item.h" +#include "history/history_item_components.h" // HistoryServicePaymentRefund. #include "info/settings/info_settings_widget.h" // SectionCustomTopBarData. #include "info/statistics/info_statistics_list_controllers.h" #include "lang/lang_keys.h" @@ -633,6 +634,33 @@ void ReceiptCreditsBox( }, button->lifetime()); } +void ShowRefundInfoBox( + not_null controller, + FullMsgId refundItemId) { + const auto owner = &controller->session().data(); + const auto item = owner->message(refundItemId); + const auto refund = item + ? item->Get() + : nullptr; + if (!refund) { + return; + } + Assert(refund->peer != nullptr); + auto info = Data::CreditsHistoryEntry(); + info.id = refund->transactionId; + info.date = base::unixtime::parse(item->date()); + info.credits = refund->amount; + info.barePeerId = refund->peer->id.value; + info.peerType = Data::CreditsHistoryEntry::PeerType::Peer; + info.refunded = true; + info.in = true; + controller->show(Box( + ::Settings::ReceiptCreditsBox, + controller, + nullptr, // premiumBot + info)); +} + object_ptr GenericEntryPhoto( not_null parent, Fn(Fn)> callback, diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.h b/Telegram/SourceFiles/settings/settings_credits_graphics.h index efea501b9ab10..406bfabcaf756 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.h +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.h @@ -54,6 +54,9 @@ void ReceiptCreditsBox( not_null controller, PeerData *premiumBot, const Data::CreditsHistoryEntry &e); +void ShowRefundInfoBox( + not_null controller, + FullMsgId refundItemId); [[nodiscard]] object_ptr GenericEntryPhoto( not_null parent, From 8ac1ad348462e7ff2475200cc9d7800312c9fcae Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 8 Jul 2024 09:20:12 +0300 Subject: [PATCH 31/36] Updated Qt to 6.2.9 on macOS. --- Telegram/build/prepare/prepare.py | 2 +- Telegram/build/qt_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Telegram/build/prepare/prepare.py b/Telegram/build/prepare/prepare.py index 8b1f71c68f956..6704bdbd28d60 100644 --- a/Telegram/build/prepare/prepare.py +++ b/Telegram/build/prepare/prepare.py @@ -445,7 +445,7 @@ def runStages(): stage('patches', """ git clone https://github.com/desktop-app/patches.git cd patches - git checkout 20a7c5ffd8 + git checkout e0cdca2e79 """) stage('msys64', """ diff --git a/Telegram/build/qt_version.py b/Telegram/build/qt_version.py index 1703e15d0f18f..2bc778741d1e8 100644 --- a/Telegram/build/qt_version.py +++ b/Telegram/build/qt_version.py @@ -2,7 +2,7 @@ def resolve(arch): if sys.platform == 'darwin': - os.environ['QT'] = '6.2.8' + os.environ['QT'] = '6.2.9' elif sys.platform == 'win32': if arch == 'arm' or 'qt6' in sys.argv: print('Choosing Qt 6.') From 3f0b962ae52b993e4c133937a552b7ad9b403dc1 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 10 Jul 2024 09:19:33 +0300 Subject: [PATCH 32/36] Fixed color reset for chat filters on saving. --- .../SourceFiles/boxes/choose_filter_box.cpp | 2 ++ .../boxes/filters/edit_filter_box.cpp | 4 +++ .../SourceFiles/data/data_chat_filters.cpp | 25 +++++++++++++++---- Telegram/SourceFiles/data/data_chat_filters.h | 4 +++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/boxes/choose_filter_box.cpp b/Telegram/SourceFiles/boxes/choose_filter_box.cpp index 5af8577bf207a..4e99a01ba855d 100644 --- a/Telegram/SourceFiles/boxes/choose_filter_box.cpp +++ b/Telegram/SourceFiles/boxes/choose_filter_box.cpp @@ -39,6 +39,7 @@ Data::ChatFilter ChangedFilter( filter.id(), filter.title(), filter.iconEmoji(), + filter.colorIndex(), filter.flags(), std::move(always), filter.pinned(), @@ -58,6 +59,7 @@ Data::ChatFilter ChangedFilter( filter.id(), filter.title(), filter.iconEmoji(), + filter.colorIndex(), filter.flags(), std::move(always), filter.pinned(), diff --git a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp index ce23d235ff551..df85e625443e0 100644 --- a/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp +++ b/Telegram/SourceFiles/boxes/filters/edit_filter_box.cpp @@ -83,6 +83,7 @@ not_null SetupChatsPreview( rules.id(), rules.title(), rules.iconEmoji(), + rules.colorIndex(), (rules.flags() & ~flag), rules.always(), rules.pinned(), @@ -104,6 +105,7 @@ not_null SetupChatsPreview( rules.id(), rules.title(), rules.iconEmoji(), + rules.colorIndex(), rules.flags(), std::move(always), std::move(pinned), @@ -170,6 +172,7 @@ void EditExceptions( rules.id(), rules.title(), rules.iconEmoji(), + rules.colorIndex(), ((rules.flags() & ~options) | rawController->chosenOptions()), include ? std::move(changed) : std::move(removeFrom), @@ -240,6 +243,7 @@ void CreateIconSelector( rules.id(), rules.title(), Ui::LookupFilterIcon(icon).emoji, + rules.colorIndex(), rules.flags(), rules.always(), rules.pinned(), diff --git a/Telegram/SourceFiles/data/data_chat_filters.cpp b/Telegram/SourceFiles/data/data_chat_filters.cpp index efac543af99dd..7a6f63a743c29 100644 --- a/Telegram/SourceFiles/data/data_chat_filters.cpp +++ b/Telegram/SourceFiles/data/data_chat_filters.cpp @@ -43,6 +43,7 @@ ChatFilter::ChatFilter( FilterId id, const QString &title, const QString &iconEmoji, + std::optional colorIndex, Flags flags, base::flat_set> always, std::vector> pinned, @@ -50,6 +51,7 @@ ChatFilter::ChatFilter( : _id(id) , _title(title) , _iconEmoji(iconEmoji) +, _colorIndex(colorIndex) , _always(std::move(always)) , _pinned(std::move(pinned)) , _never(std::move(never)) @@ -95,6 +97,9 @@ ChatFilter ChatFilter::FromTL( data.vid().v, qs(data.vtitle()), qs(data.vemoticon().value_or_empty()), + data.vcolor() + ? std::make_optional(data.vcolor()->v) + : std::nullopt, flags, std::move(list), std::move(pinned), @@ -140,6 +145,9 @@ ChatFilter ChatFilter::FromTL( data.vid().v, qs(data.vtitle()), qs(data.vemoticon().value_or_empty()), + data.vcolor() + ? std::make_optional(data.vcolor()->v) + : std::nullopt, (Flag::Chatlist | (data.is_has_my_invites() ? Flag::HasMyLinks : Flag())), std::move(list), @@ -189,18 +197,20 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const { } if (_flags & Flag::Chatlist) { using TLFlag = MTPDdialogFilterChatlist::Flag; - const auto flags = TLFlag::f_emoticon; + const auto flags = TLFlag::f_emoticon + | (_colorIndex ? TLFlag::f_color : TLFlag(0)); return MTP_dialogFilterChatlist( MTP_flags(flags), MTP_int(replaceId ? replaceId : _id), MTP_string(_title), MTP_string(_iconEmoji), - MTPint(), // color + MTP_int(_colorIndex.value_or(0)), MTP_vector(pinned), MTP_vector(include)); } using TLFlag = MTPDdialogFilter::Flag; const auto flags = TLFlag::f_emoticon + | (_colorIndex ? TLFlag::f_color : TLFlag(0)) | ((_flags & Flag::Contacts) ? TLFlag::f_contacts : TLFlag(0)) | ((_flags & Flag::NonContacts) ? TLFlag::f_non_contacts : TLFlag(0)) | ((_flags & Flag::Groups) ? TLFlag::f_groups : TLFlag(0)) @@ -221,7 +231,7 @@ MTPDialogFilter ChatFilter::tl(FilterId replaceId) const { MTP_int(replaceId ? replaceId : _id), MTP_string(_title), MTP_string(_iconEmoji), - MTPint(), // color + MTP_int(_colorIndex.value_or(0)), MTP_vector(pinned), MTP_vector(include), MTP_vector(never)); @@ -239,6 +249,10 @@ QString ChatFilter::iconEmoji() const { return _iconEmoji; } +std::optional ChatFilter::colorIndex() const { + return _colorIndex; +} + ChatFilter::Flags ChatFilter::flags() const { return _flags; } @@ -555,7 +569,7 @@ void ChatFilters::applyInsert(ChatFilter filter, int position) { _list.insert( begin(_list) + position, - ChatFilter(filter.id(), {}, {}, {}, {}, {}, {})); + ChatFilter(filter.id(), {}, {}, {}, {}, {}, {}, {})); applyChange(*(begin(_list) + position), std::move(filter)); } @@ -582,7 +596,7 @@ void ChatFilters::applyRemove(int position) { Expects(position >= 0 && position < _list.size()); const auto i = begin(_list) + position; - applyChange(*i, ChatFilter(i->id(), {}, {}, {}, {}, {}, {})); + applyChange(*i, ChatFilter(i->id(), {}, {}, {}, {}, {}, {}, {})); _list.erase(i); } @@ -711,6 +725,7 @@ const ChatFilter &ChatFilters::applyUpdatedPinned( id, i->title(), i->iconEmoji(), + i->colorIndex(), i->flags(), std::move(always), std::move(pinned), diff --git a/Telegram/SourceFiles/data/data_chat_filters.h b/Telegram/SourceFiles/data/data_chat_filters.h index 7b5a96476853c..e123ab2c15684 100644 --- a/Telegram/SourceFiles/data/data_chat_filters.h +++ b/Telegram/SourceFiles/data/data_chat_filters.h @@ -52,6 +52,7 @@ class ChatFilter final { FilterId id, const QString &title, const QString &iconEmoji, + std::optional colorIndex, Flags flags, base::flat_set> always, std::vector> pinned, @@ -71,6 +72,7 @@ class ChatFilter final { [[nodiscard]] FilterId id() const; [[nodiscard]] QString title() const; [[nodiscard]] QString iconEmoji() const; + [[nodiscard]] std::optional colorIndex() const; [[nodiscard]] Flags flags() const; [[nodiscard]] bool chatlist() const; [[nodiscard]] bool hasMyLinks() const; @@ -84,6 +86,7 @@ class ChatFilter final { FilterId _id = 0; QString _title; QString _iconEmoji; + std::optional _colorIndex; base::flat_set> _always; std::vector> _pinned; base::flat_set> _never; @@ -94,6 +97,7 @@ class ChatFilter final { inline bool operator==(const ChatFilter &a, const ChatFilter &b) { return (a.title() == b.title()) && (a.iconEmoji() == b.iconEmoji()) + && (a.colorIndex() == b.colorIndex()) && (a.flags() == b.flags()) && (a.always() == b.always()) && (a.never() == b.never()); From 6818b8d8dc6d8f21754bc823b620d5be9575b355 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 14 Jul 2024 22:22:05 +0300 Subject: [PATCH 33/36] Fixed row name in table for credits history entries in earn box. --- Telegram/Resources/langs/lang.strings | 1 + Telegram/SourceFiles/boxes/gift_premium_box.cpp | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 0c60906ec3767..e7b50f139b2df 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2364,6 +2364,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_summary_in_toast_about#one" = "**{count}** Star added to your balance."; "lng_credits_summary_in_toast_about#other" = "**{count}** Stars added to your balance."; "lng_credits_box_history_entry_peer" = "Recipient"; +"lng_credits_box_history_entry_peer_in" = "From"; "lng_credits_box_history_entry_via" = "Via"; "lng_credits_box_history_entry_play_market" = "Play Market"; "lng_credits_box_history_entry_app_store" = "App Store"; diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 972a7a5f44d1c..58dc2941faebf 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1648,7 +1648,9 @@ void AddCreditsHistoryEntryTable( st::giveawayGiftCodeTableMargin); const auto peerId = PeerId(entry.barePeerId); if (peerId) { - auto text = tr::lng_credits_box_history_entry_peer(); + auto text = entry.in + ? tr::lng_credits_box_history_entry_peer_in() + : tr::lng_credits_box_history_entry_peer(); AddTableRow(table, std::move(text), controller, peerId); } if (const auto msgId = MsgId(peerId ? entry.bareMsgId : 0)) { From 1d5e4040f408d1d6541d10c0a4f57491a4b551d4 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sun, 14 Jul 2024 22:59:27 +0300 Subject: [PATCH 34/36] Added api support of flag to view credits stats from full channel. --- Telegram/SourceFiles/data/data_channel.cpp | 8 ++++++-- Telegram/SourceFiles/data/data_channel.h | 1 + .../channel_statistics/earn/info_channel_earn_list.cpp | 9 ++++++++- Telegram/SourceFiles/window/window_peer_menu.cpp | 4 +++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/data/data_channel.cpp b/Telegram/SourceFiles/data/data_channel.cpp index 2f76943950e54..6162024fd9793 100644 --- a/Telegram/SourceFiles/data/data_channel.cpp +++ b/Telegram/SourceFiles/data/data_channel.cpp @@ -1089,7 +1089,8 @@ void ApplyChannelUpdate( | Flag::CanGetStatistics | Flag::ViewAsMessages | Flag::CanViewRevenue - | Flag::PaidMediaAllowed; + | Flag::PaidMediaAllowed + | Flag::CanViewCreditsRevenue; channel->setFlags((channel->flags() & ~mask) | (update.is_can_set_username() ? Flag::CanSetUsername : Flag()) | (update.is_can_view_participants() @@ -1107,7 +1108,10 @@ void ApplyChannelUpdate( ? Flag::ViewAsMessages : Flag()) | (update.is_paid_media_allowed() ? Flag::PaidMediaAllowed : Flag()) - | (update.is_can_view_revenue() ? Flag::CanViewRevenue : Flag())); + | (update.is_can_view_revenue() ? Flag::CanViewRevenue : Flag()) + | (update.is_can_view_stars_revenue() + ? Flag::CanViewCreditsRevenue + : Flag())); channel->setUserpicPhoto(update.vchat_photo()); if (const auto migratedFrom = update.vmigrated_from_chat_id()) { channel->addFlags(Flag::Megagroup); diff --git a/Telegram/SourceFiles/data/data_channel.h b/Telegram/SourceFiles/data/data_channel.h index d6f880bdae75b..81ad7778dd18b 100644 --- a/Telegram/SourceFiles/data/data_channel.h +++ b/Telegram/SourceFiles/data/data_channel.h @@ -67,6 +67,7 @@ enum class ChannelDataFlag : uint64 { SimilarExpanded = (1ULL << 31), CanViewRevenue = (1ULL << 32), PaidMediaAllowed = (1ULL << 33), + CanViewCreditsRevenue = (1ULL << 34), }; inline constexpr bool is_flag_type(ChannelDataFlag) { return true; }; using ChannelDataFlags = base::flags; diff --git a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp index 84ad81390fb81..c16acc204c45b 100644 --- a/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp +++ b/Telegram/SourceFiles/info/channel_statistics/earn/info_channel_earn_list.cpp @@ -281,6 +281,9 @@ void InnerWidget::load() { rpl::lifetime apiPremiumBotLifetime; }; const auto state = lifetime().make_state(_peer); + using ChannelFlag = ChannelDataFlag; + const auto canViewCredits = !_peer->isChannel() + || (_peer->asChannel()->flags() & ChannelFlag::CanViewCreditsRevenue); Info::Statistics::FillLoading( this, @@ -363,7 +366,11 @@ void InnerWidget::load() { _state.premiumBotId = bot->id; state->apiCredits.request( ) | rpl::start_with_error_done([=](const QString &error) { - fail(error); + if (canViewCredits) { + fail(error); + } else { + _state.creditsEarn = {}; + } finish(); }, [=] { _state.creditsEarn = state->apiCredits.data(); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index f8259eec76b9d..74f6f7ed864ac 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1090,6 +1090,8 @@ void Filler::addViewStatistics() { using Flag = ChannelDataFlag; const auto canGetStats = (channel->flags() & Flag::CanGetStatistics); const auto canViewEarn = (channel->flags() & Flag::CanViewRevenue); + const auto canViewCreditsEarn + = (channel->flags() & Flag::CanViewCreditsRevenue); if (canGetStats) { _addAction(tr::lng_stats_title(tr::now), [=] { if (const auto strong = weak.get()) { @@ -1107,7 +1109,7 @@ void Filler::addViewStatistics() { } }, &st::menuIconBoosts); } - if (canViewEarn) { + if (canViewEarn || canViewCreditsEarn) { _addAction(tr::lng_channel_earn_title(tr::now), [=] { if (const auto strong = weak.get()) { controller->showSection(Info::ChannelEarn::Make(peer)); From 4b9eb37bd53503c856a8e4d3014636f15b84b9ef Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 15 Jul 2024 00:05:19 +0300 Subject: [PATCH 35/36] Added phrases for single winner of giveaway in channels. --- Telegram/Resources/langs/lang.strings | 3 +++ Telegram/SourceFiles/data/data_media_types.cpp | 6 +++++- .../history/view/media/history_view_giveaway.cpp | 12 +++++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index e7b50f139b2df..451f34da56d91 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2813,12 +2813,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_prizes_badge" = "x{amount}"; "lng_prizes_results_title" = "Winners Selected!"; +"lng_prizes_results_title_one" = "Winner Selected!"; "lng_prizes_results_about#one" = "**{count}** winner of the {link} was randomly selected by Telegram."; "lng_prizes_results_about#other" = "**{count}** winners of the {link} were randomly selected by Telegram."; "lng_prizes_results_link" = "Giveaway"; +"lng_prizes_results_winner" = "Winner"; "lng_prizes_results_winners" = "Winners"; "lng_prizes_results_more#one" = "and {count} more!"; "lng_prizes_results_more#other" = "and {count} more!"; +"lng_prizes_results_one" = "The winner received their gift link in a private message."; "lng_prizes_results_all" = "All winners received gift links in private messages."; "lng_prizes_results_some" = "Some winners couldn't be selected."; diff --git a/Telegram/SourceFiles/data/data_media_types.cpp b/Telegram/SourceFiles/data/data_media_types.cpp index a7b2690eab0d2..da16410b0366f 100644 --- a/Telegram/SourceFiles/data/data_media_types.cpp +++ b/Telegram/SourceFiles/data/data_media_types.cpp @@ -2631,7 +2631,11 @@ const GiveawayResults *MediaGiveawayResults::giveawayResults() const { } TextWithEntities MediaGiveawayResults::notificationText() const { - return Ui::Text::Colorized({ tr::lng_prizes_results_title(tr::now) }); + return Ui::Text::Colorized({ + ((_data.winnersCount == 1) + ? tr::lng_prizes_results_title_one + : tr::lng_prizes_results_title)(tr::now) + }); } QString MediaGiveawayResults::pinnedTextSubstring() const { diff --git a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp index 310af8fa6a0bb..f2f98d05e37c8 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_giveaway.cpp @@ -200,9 +200,11 @@ auto GenerateGiveawayResults( margins, links)); }; + const auto isSingleWinner = (data->winnersCount == 1); pushText( - Ui::Text::Bold( - tr::lng_prizes_results_title(tr::now)), + (isSingleWinner + ? tr::lng_prizes_results_title_one + : tr::lng_prizes_results_title)(tr::now, Ui::Text::Bold), st::chatGiveawayPrizesTitleMargin); const auto showGiveawayHandler = JumpToMessageClickHandler( data->channel, @@ -219,7 +221,9 @@ auto GenerateGiveawayResults( st::chatGiveawayPrizesMargin, { { 1, showGiveawayHandler } }); pushText( - Ui::Text::Bold(tr::lng_prizes_results_winners(tr::now)), + (isSingleWinner + ? tr::lng_prizes_results_winner + : tr::lng_prizes_results_winners)(tr::now, Ui::Text::Bold), st::chatGiveawayPrizesTitleMargin); push(std::make_unique( @@ -235,6 +239,8 @@ auto GenerateGiveawayResults( } pushText({ data->unclaimedCount ? tr::lng_prizes_results_some(tr::now) + : isSingleWinner + ? tr::lng_prizes_results_one(tr::now) : tr::lng_prizes_results_all(tr::now) }, st::chatGiveawayEndDateMargin); }; From 4f7a124f3e85f3f61d862b94fb5a45236976f38f Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 15 Jul 2024 00:37:33 +0300 Subject: [PATCH 36/36] Added phrases to credits history entries when peer type is premium bot. --- Telegram/Resources/langs/lang.strings | 2 ++ .../SourceFiles/boxes/gift_premium_box.cpp | 6 ++++ .../info_statistics_list_controllers.cpp | 2 -- .../settings/settings_credits_graphics.cpp | 29 ++++++++++++++++++- .../ui/effects/credits_graphics.cpp | 21 +++++++++++--- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 451f34da56d91..5c461c1efdb7a 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -2370,6 +2370,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_credits_box_history_entry_app_store" = "App Store"; "lng_credits_box_history_entry_fragment" = "Fragment"; "lng_credits_box_history_entry_ads" = "Ads Platform"; +"lng_credits_box_history_entry_premium_bot" = "Stars Top-Up"; +"lng_credits_box_history_entry_via_premium_bot" = "Premium Bot"; "lng_credits_box_history_entry_id" = "Transaction ID"; "lng_credits_box_history_entry_id_copied" = "Transaction ID copied to clipboard."; "lng_credits_box_history_entry_success_date" = "Transaction date"; diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 58dc2941faebf..fdf1eda03f30b 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -1702,6 +1702,12 @@ void AddCreditsHistoryEntryTable( table, tr::lng_credits_box_history_entry_via(), tr::lng_credits_box_history_entry_ads(Ui::Text::RichLangValue)); + } else if (entry.peerType == Type::PremiumBot) { + AddTableRow( + table, + tr::lng_credits_box_history_entry_via(), + tr::lng_credits_box_history_entry_via_premium_bot( + Ui::Text::RichLangValue)); } if (!entry.id.isEmpty()) { constexpr auto kOneLineCount = 18; diff --git a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp index 956c7d0c37bc0..a176be565d46e 100644 --- a/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp +++ b/Telegram/SourceFiles/info/statistics/info_statistics_list_controllers.cpp @@ -954,8 +954,6 @@ void CreditsController::applySlice(const Data::CreditsStatusSlice &slice) { if (const auto peerId = PeerId(item.barePeerId)) { const auto peer = session().data().peer(peerId); return std::make_unique(peer, descriptor); - } else if (item.peerType == Type::PremiumBot) { - return std::make_unique(_premiumBot, descriptor); } else { return std::make_unique(descriptor); } diff --git a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp index 3b88e8d484fb9..282945d9efc73 100644 --- a/Telegram/SourceFiles/settings/settings_credits_graphics.cpp +++ b/Telegram/SourceFiles/settings/settings_credits_graphics.cpp @@ -448,7 +448,7 @@ void ReceiptCreditsBox( const auto &stUser = st::boostReplaceUserpic; const auto session = &controller->session(); const auto peer = (e.peerType == Type::PremiumBot) - ? premiumBot + ? nullptr : e.barePeerId ? session->data().peer(PeerId(e.barePeerId)).get() : nullptr; @@ -622,6 +622,33 @@ void ReceiptCreditsBox( Ui::AddSkip(content); + if (e.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) { + const auto widget = Ui::CreateChild(content); + using ColoredMiniStars = Ui::Premium::ColoredMiniStars; + const auto stars = widget->lifetime().make_state( + widget, + false, + Ui::Premium::MiniStars::Type::BiStars); + stars->setColorOverride(Ui::Premium::CreditsIconGradientStops()); + widget->resize( + st::boxWidth - stUser.photoSize, + stUser.photoSize * 2); + content->sizeValue( + ) | rpl::start_with_next([=](const QSize &size) { + widget->moveToLeft(stUser.photoSize / 2, 0); + const auto starsRect = Rect(widget->size()); + stars->setPosition(starsRect.topLeft()); + stars->setSize(starsRect.size()); + widget->lower(); + }, widget->lifetime()); + widget->paintRequest( + ) | rpl::start_with_next([=](const QRect &r) { + auto p = QPainter(widget); + p.fillRect(r, Qt::transparent); + stars->paint(p); + }, widget->lifetime()); + } + const auto button = box->addButton(tr::lng_box_ok(), [=] { box->closeBox(); }); diff --git a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp index 3f4ce02f2ca90..e99a4d4eb37af 100644 --- a/Telegram/SourceFiles/ui/effects/credits_graphics.cpp +++ b/Telegram/SourceFiles/ui/effects/credits_graphics.cpp @@ -193,6 +193,21 @@ not_null AddInputFieldForCredits( PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( const Data::CreditsHistoryEntry &entry) { + using PeerType = Data::CreditsHistoryEntry::PeerType; + if (entry.peerType == PeerType::PremiumBot) { + const auto svg = std::make_shared(Ui::Premium::Svg()); + return [=](Painter &p, int x, int y, int, int size) mutable { + const auto hq = PainterHighQualityEnabler(p); + p.setPen(Qt::NoPen); + { + auto gradient = QLinearGradient(x + size, y + size, x, y); + gradient.setStops(Ui::Premium::ButtonGradientStops()); + p.setBrush(gradient); + } + p.drawEllipse(x, y, size, size); + svg->render(&p, QRectF(x, y, size, size) - Margins(size / 5.)); + }; + } const auto bg = [&]() -> EmptyUserpic::BgColors { switch (entry.peerType) { case Data::CreditsHistoryEntry::PeerType::Peer: @@ -218,10 +233,6 @@ PaintRoundImageCallback GenerateCreditsPaintUserpicCallback( const auto userpic = std::make_shared(bg, QString()); return [=](Painter &p, int x, int y, int outerWidth, int size) mutable { userpic->paintCircle(p, x, y, outerWidth, size); - using PeerType = Data::CreditsHistoryEntry::PeerType; - if (entry.peerType == PeerType::PremiumBot) { - return; - } const auto rect = QRect(x, y, size, size); ((entry.peerType == PeerType::AppStore) ? st::sessionIconiPhone @@ -446,6 +457,8 @@ Fn)> PaintPreviewCallback( TextWithEntities GenerateEntryName(const Data::CreditsHistoryEntry &entry) { return ((entry.peerType == Data::CreditsHistoryEntry::PeerType::Fragment) ? tr::lng_bot_username_description1_link + : (entry.peerType == Data::CreditsHistoryEntry::PeerType::PremiumBot) + ? tr::lng_credits_box_history_entry_premium_bot : (entry.peerType == Data::CreditsHistoryEntry::PeerType::Ads) ? tr::lng_credits_box_history_entry_ads : tr::lng_credits_summary_history_entry_inner_in)(