From 2ef8136308e31e07988ee4654b73ae2a5ab495dc Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 6 Jan 2024 12:56:19 +0400 Subject: [PATCH 01/73] Update patches commit in Dockerfile --- Telegram/build/docker/centos_env/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index d2c6320a00..bad748eb1c 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -54,7 +54,7 @@ FROM builder AS patches RUN git init patches \ && cd patches \ && git remote add origin {{ GIT }}/desktop-app/patches.git \ - && git fetch --depth=1 origin 1e6c830a66649a60a2a277015143260f5716517b \ + && git fetch --depth=1 origin aadb3de1f4b259d64c6a9133fbd2931508a00faa \ && git reset --hard FETCH_HEAD \ && rm -rf .git From 30d5b7fd6651eb1425e77e83edf0b75f645068e2 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Mon, 8 Jan 2024 16:16:22 +0400 Subject: [PATCH 02/73] Update patches commit in Dockerfile --- Telegram/build/docker/centos_env/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index bad748eb1c..c9031a76d9 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -54,7 +54,7 @@ FROM builder AS patches RUN git init patches \ && cd patches \ && git remote add origin {{ GIT }}/desktop-app/patches.git \ - && git fetch --depth=1 origin aadb3de1f4b259d64c6a9133fbd2931508a00faa \ + && git fetch --depth=1 origin 4ff99fa2d8836f2cd9befe6cf38ce87dc20f276b \ && git reset --hard FETCH_HEAD \ && rm -rf .git From 893e14cc395d6358be84889eefe00fa506e7ef26 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 8 Jan 2024 17:34:08 +0400 Subject: [PATCH 03/73] Fix payment field values formatting. Regression was introduced in e6b9a07163. Fixes #27318. --- Telegram/SourceFiles/payments/ui/payments_field.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/payments/ui/payments_field.cpp b/Telegram/SourceFiles/payments/ui/payments_field.cpp index e182714e30..1314674ce2 100644 --- a/Telegram/SourceFiles/payments/ui/payments_field.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_field.cpp @@ -217,10 +217,10 @@ struct SimpleFieldState { const FieldConfig &config, const QString &parsed, const QString &countryIso2) { - static const auto RegExp = QRegularExpression("[^0-9]\\."); if (config.type == FieldType::Country) { return countryIso2; } else if (config.type == FieldType::Money) { + static const auto RegExp = QRegularExpression("[^0-9\\.]"); const auto rule = LookupCurrencyRule(config.currency); const auto real = QString(parsed).replace( QChar(rule.decimal), @@ -236,6 +236,7 @@ struct SimpleFieldState { int64(base::SafeRound(real * std::pow(10., rule.exponent)))); } else if (config.type == FieldType::CardNumber || config.type == FieldType::CardCVC) { + static const auto RegExp = QRegularExpression("[^0-9]"); return QString(parsed).replace(RegExp, QString()); } return parsed; From c257b75a667acb597e3c7d4e58d809c8fc1775ce Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jan 2024 12:05:16 +0400 Subject: [PATCH 04/73] Add poll creation to the attach menu. --- .../inline_bots/bot_attach_web_view.cpp | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index 1a2703675c..da0b08d7e2 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -32,6 +32,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "ui/painter.h" #include "window/themes/window_theme.h" #include "window/window_controller.h" +#include "window/window_peer_menu.h" #include "window/window_session_controller.h" #include "webview/webview_interface.h" #include "core/application.h" @@ -1660,6 +1661,28 @@ std::unique_ptr MakeAttachBotsMenu( attach(false); }, &st::menuIconFile); } + if (peer->canCreatePolls()) { + ++minimal; + raw->addAction(tr::lng_polls_create(tr::now), [=] { + const auto action = actionFactory(); + const auto source = action.options.scheduled + ? Api::SendType::Scheduled + : Api::SendType::Normal; + const auto sendMenuType = action.replyTo.topicRootId + ? SendMenu::Type::SilentOnly + : SendMenu::Type::Scheduled; + const auto flag = PollData::Flags(); + const auto replyTo = action.replyTo; + Window::PeerMenuCreatePoll( + controller, + peer, + replyTo, + flag, + flag, + source, + sendMenuType); + }, &st::menuIconCreatePoll); + } for (const auto &bot : bots->attachBots()) { if (!bot.inAttachMenu || !PeerMatchesTypes(peer, bot.user, bot.types)) { From 28b43eff7c3937bc1d0ce10a974311b6a93f3961 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Jan 2024 12:50:04 +0400 Subject: [PATCH 05/73] Make Ctrl+Shift+[1-6] jump through accounts. --- Telegram/SourceFiles/core/shortcuts.cpp | 15 +++++++ Telegram/SourceFiles/core/shortcuts.h | 16 ++++++++ .../window/window_session_controller.cpp | 39 ++++++++++++++++--- .../window/window_session_controller.h | 2 +- 4 files changed, 66 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/core/shortcuts.cpp b/Telegram/SourceFiles/core/shortcuts.cpp index f673aba28f..56158e2b52 100644 --- a/Telegram/SourceFiles/core/shortcuts.cpp +++ b/Telegram/SourceFiles/core/shortcuts.cpp @@ -80,6 +80,13 @@ const auto CommandByName = base::flat_map{ { u"next_folder"_q , Command::FolderNext }, { u"all_chats"_q , Command::ShowAllChats }, + { u"account1"_q , Command::ShowAccount1 }, + { u"account2"_q , Command::ShowAccount2 }, + { u"account3"_q , Command::ShowAccount3 }, + { u"account4"_q , Command::ShowAccount4 }, + { u"account5"_q , Command::ShowAccount5 }, + { u"account6"_q , Command::ShowAccount6 }, + { u"folder1"_q , Command::ShowFolder1 }, { u"folder2"_q , Command::ShowFolder2 }, { u"folder3"_q , Command::ShowFolder3 }, @@ -392,6 +399,14 @@ void Manager::fillDefaults() { set(u"%1+%2"_q.arg(ctrl).arg(index), command); } + auto &&accounts = ranges::views::zip( + kShowAccount, + ranges::views::ints(1, ranges::unreachable)); + + for (const auto [command, index] : accounts) { + set(u"%1+shift+%2"_q.arg(ctrl).arg(index), command); + } + set(u"%1+shift+down"_q.arg(ctrl), Command::FolderNext); set(u"%1+shift+up"_q.arg(ctrl), Command::FolderPrevious); diff --git a/Telegram/SourceFiles/core/shortcuts.h b/Telegram/SourceFiles/core/shortcuts.h index d7b3dc3c5e..b562517d5c 100644 --- a/Telegram/SourceFiles/core/shortcuts.h +++ b/Telegram/SourceFiles/core/shortcuts.h @@ -38,6 +38,13 @@ enum class Command { ChatPinned7, ChatPinned8, + ShowAccount1, + ShowAccount2, + ShowAccount3, + ShowAccount4, + ShowAccount5, + ShowAccount6, + ShowAllChats, ShowFolder1, ShowFolder2, @@ -79,6 +86,15 @@ enum class Command { Command::ShowFolderLast, }; +[[maybe_unused]] constexpr auto kShowAccount = { + Command::ShowAccount1, + Command::ShowAccount2, + Command::ShowAccount3, + Command::ShowAccount4, + Command::ShowAccount5, + Command::ShowAccount6, +}; + [[nodiscard]] FnMut RequestHandler(Command command); class Request { diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 454e525f60..3f78e1850a 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -1224,19 +1224,48 @@ void SessionController::showGiftPremiumsBox(const QString &ref) { void SessionController::init() { if (session().supportMode()) { - initSupportMode(); + session().supportHelper().registerWindow(this); } + setupShortcuts(); } -void SessionController::initSupportMode() { - session().supportHelper().registerWindow(this); - +void SessionController::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { - return (Core::App().activeWindow() == &window()); + return (Core::App().activeWindow() == &window()) + && !isLayerShown() + && !window().locked(); }) | rpl::start_with_next([=](not_null request) { using C = Shortcuts::Command; + const auto app = &Core::App(); + const auto accountsCount = int(app->domain().accounts().size()); + auto &&accounts = ranges::views::zip( + Shortcuts::kShowAccount, + ranges::views::ints(0, accountsCount)); + for (const auto [command, index] : accounts) { + request->check(command) && request->handle([=] { + const auto list = app->domain().orderedAccounts(); + if (index >= list.size()) { + return false; + } + const auto account = list[index]; + if (account == &session().account()) { + return false; + } + const auto window = app->separateWindowForAccount(account); + if (window) { + window->activate(); + } else { + app->domain().maybeActivate(account); + } + return true; + }); + } + + if (!session().supportMode()) { + return; + } request->check(C::SupportHistoryBack) && request->handle([=] { return chatEntryHistoryMove(-1); }); diff --git a/Telegram/SourceFiles/window/window_session_controller.h b/Telegram/SourceFiles/window/window_session_controller.h index 03a60fcac5..4ef7b17916 100644 --- a/Telegram/SourceFiles/window/window_session_controller.h +++ b/Telegram/SourceFiles/window/window_session_controller.h @@ -601,7 +601,7 @@ private: struct CachedTheme; void init(); - void initSupportMode(); + void setupShortcuts(); void refreshFiltersMenu(); void checkOpenedFilter(); void suggestArchiveAndMute(); From 0f207faa3eac0ce4d3eb628a4e243050df069e53 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 8 Jan 2024 17:47:03 +0400 Subject: [PATCH 06/73] Version 4.14.4. - Switch between logged in accounts using Ctrl+Shift+[1-6] shortcuts. - Add poll creation in groups to the attach menu, if exists. - Another fix for payment card validation. --- 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 | 6 ++++++ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/uwp/AppX/AppxManifest.xml b/Telegram/Resources/uwp/AppX/AppxManifest.xml index bc517dc13f..8030e5cba1 100644 --- a/Telegram/Resources/uwp/AppX/AppxManifest.xml +++ b/Telegram/Resources/uwp/AppX/AppxManifest.xml @@ -10,7 +10,7 @@ + Version="4.14.4.0" /> Telegram Desktop Telegram Messenger LLP diff --git a/Telegram/Resources/winrc/Telegram.rc b/Telegram/Resources/winrc/Telegram.rc index ec675b7e32..158616895a 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 4,14,3,0 - PRODUCTVERSION 4,14,3,0 + FILEVERSION 4,14,4,0 + PRODUCTVERSION 4,14,4,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -62,10 +62,10 @@ BEGIN BEGIN VALUE "CompanyName", "Telegram FZ-LLC" VALUE "FileDescription", "Telegram Desktop" - VALUE "FileVersion", "4.14.3.0" + VALUE "FileVersion", "4.14.4.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.14.3.0" + VALUE "ProductVersion", "4.14.4.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/Resources/winrc/Updater.rc b/Telegram/Resources/winrc/Updater.rc index 26208ac824..bfc6ab89c1 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 4,14,3,0 - PRODUCTVERSION 4,14,3,0 + FILEVERSION 4,14,4,0 + PRODUCTVERSION 4,14,4,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", "4.14.3.0" + VALUE "FileVersion", "4.14.4.0" VALUE "LegalCopyright", "Copyright (C) 2014-2024" VALUE "ProductName", "Telegram Desktop" - VALUE "ProductVersion", "4.14.3.0" + VALUE "ProductVersion", "4.14.4.0" END END BLOCK "VarFileInfo" diff --git a/Telegram/SourceFiles/core/version.h b/Telegram/SourceFiles/core/version.h index 939e36683d..d6e18ed788 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 = 4014003; -constexpr auto AppVersionStr = "4.14.3"; +constexpr auto AppVersion = 4014004; +constexpr auto AppVersionStr = "4.14.4"; constexpr auto AppBetaVersion = false; constexpr auto AppAlphaVersion = TDESKTOP_ALPHA_VERSION; diff --git a/Telegram/build/version b/Telegram/build/version index beba60eed6..7f191e54d7 100644 --- a/Telegram/build/version +++ b/Telegram/build/version @@ -1,7 +1,7 @@ -AppVersion 4014003 +AppVersion 4014004 AppVersionStrMajor 4.14 -AppVersionStrSmall 4.14.3 -AppVersionStr 4.14.3 +AppVersionStrSmall 4.14.4 +AppVersionStr 4.14.4 BetaChannel 0 AlphaVersion 0 -AppVersionOriginal 4.14.3 +AppVersionOriginal 4.14.4 diff --git a/changelog.txt b/changelog.txt index da9a23547f..06857dfacf 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +4.14.4 (08.01.24) + +- Switch between logged in accounts using Ctrl+Shift+[1-6] shortcuts. +- Add poll creation in groups to the attach menu, if exists. +- Another fix for payment card validation. + 4.14.3 (04.01.24) - Allow sending single-time voice messages. From 6b44143f5b93f85fb2c479fe970f7efef5ef9c8a Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 8 Jan 2024 12:03:49 -0800 Subject: [PATCH 07/73] Version 4.14.4: Fix build with GCC. --- Telegram/SourceFiles/api/api_sending.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Telegram/SourceFiles/api/api_sending.cpp b/Telegram/SourceFiles/api/api_sending.cpp index d971a03f44..0e5d7c5855 100644 --- a/Telegram/SourceFiles/api/api_sending.cpp +++ b/Telegram/SourceFiles/api/api_sending.cpp @@ -402,7 +402,6 @@ void SendConfirmedFile( flags |= MessageFlag::HasReplyInfo; } const auto anonymousPost = peer->amAnonymous(); - const auto silentPost = ShouldSendSilent(peer, file->to.options); FillMessagePostFlags(action, peer, flags); if (file->to.options.scheduled) { flags |= MessageFlag::IsOrWasScheduled; From 7779d021b4d4e04e80d954f1f19416951354135a Mon Sep 17 00:00:00 2001 From: Klemens Nanni Date: Mon, 8 Jan 2024 22:49:46 +0100 Subject: [PATCH 08/73] update cmake/ submodule to include cppgir BSD fixes --- cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake b/cmake index 9620c46740..e541d6577d 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 9620c467404f15a01bb5271af02b2676c2aaf306 +Subproject commit e541d6577d542c0e42788341c2ebf0b54e354461 From 26fa3db66d458f8ae113a8634526f432e2b177bd Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 9 Jan 2024 16:24:55 +0400 Subject: [PATCH 09/73] Replace deprecated medium display length with a number --- lib/xdg/org.telegram.desktop.metainfo.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/xdg/org.telegram.desktop.metainfo.xml b/lib/xdg/org.telegram.desktop.metainfo.xml index d787eada95..810a52b0b9 100644 --- a/lib/xdg/org.telegram.desktop.metainfo.xml +++ b/lib/xdg/org.telegram.desktop.metainfo.xml @@ -45,12 +45,14 @@ im - medium + + 480 always + + keyboard pointing - keyboard touch From 8138a26c2d761efa93069d8405649db1e85787a4 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 9 Jan 2024 16:25:29 +0400 Subject: [PATCH 10/73] Add information about provided mime-type and D-Bus service --- lib/xdg/org.telegram.desktop.metainfo.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/xdg/org.telegram.desktop.metainfo.xml b/lib/xdg/org.telegram.desktop.metainfo.xml index 810a52b0b9..874bbc2beb 100644 --- a/lib/xdg/org.telegram.desktop.metainfo.xml +++ b/lib/xdg/org.telegram.desktop.metainfo.xml @@ -88,5 +88,7 @@ org.telegram.desktop.desktop telegram-desktop + org.telegram.desktop + x-scheme-handler/tg From aa121aa1de79402c930e3ea2ad79508e35d64e6c Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Tue, 9 Jan 2024 23:22:46 +0400 Subject: [PATCH 11/73] Get rid of architecture whitelist from snapcraft.yaml So the Canonical builders build on new architectures as soon as they appear --- snap/snapcraft.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 16e8914b63..41dc00828e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -7,12 +7,6 @@ grade: stable confinement: strict compression: lzo -architectures: - - build-on: amd64 - - build-on: arm64 - - build-on: armhf - - build-on: ppc64el - apps: telegram-desktop: command: usr/bin/telegram-desktop From d803b3ae7d386f926742aad76856432056f0c624 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 10 Jan 2024 07:01:22 +0400 Subject: [PATCH 12/73] Try to add mesa vulkan drivers to snap --- snap/snapcraft.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 41dc00828e..4b28983d80 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -491,6 +491,7 @@ parts: - libxkbcommon0 - libxkbcommon-x11-0 - zlib1g + - mesa-vulkan-drivers override-pull: | QT=6.6.1 From 308fdcf9cf8d11042f778bfb478a4c298116ff74 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 10 Jan 2024 09:59:34 +0400 Subject: [PATCH 13/73] Update submodules --- Telegram/build/docker/centos_env/Dockerfile | 2 +- Telegram/lib_ui | 2 +- Telegram/lib_webview | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Telegram/build/docker/centos_env/Dockerfile b/Telegram/build/docker/centos_env/Dockerfile index c9031a76d9..ad9a284385 100644 --- a/Telegram/build/docker/centos_env/Dockerfile +++ b/Telegram/build/docker/centos_env/Dockerfile @@ -54,7 +54,7 @@ FROM builder AS patches RUN git init patches \ && cd patches \ && git remote add origin {{ GIT }}/desktop-app/patches.git \ - && git fetch --depth=1 origin 4ff99fa2d8836f2cd9befe6cf38ce87dc20f276b \ + && git fetch --depth=1 origin a63f0887630c3e2130ee60ef322dd51ae3983c88 \ && git reset --hard FETCH_HEAD \ && rm -rf .git diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 30c5dfe6f6..00f5bdaccd 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 30c5dfe6f65babf234c889959061c97c4a2f391d +Subproject commit 00f5bdaccdff4f53e8ba347f09f2de161b7ca7da diff --git a/Telegram/lib_webview b/Telegram/lib_webview index 63e4ba48fd..a1c84d636f 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit 63e4ba48fd8540fa3c2949d123160a2ce3411d70 +Subproject commit a1c84d636f7975781dece08939bbc24da8298c3c From 1e98e19aaf8f11449164b24e6b437f7798cb1a44 Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Wed, 10 Jan 2024 10:38:59 +0400 Subject: [PATCH 14/73] Add installed packages to cache key for macOS packaged action --- .github/workflows/mac_packaged.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/mac_packaged.yml b/.github/workflows/mac_packaged.yml index 631ff2a70a..51ba9917a1 100644 --- a/.github/workflows/mac_packaged.yml +++ b/.github/workflows/mac_packaged.yml @@ -73,6 +73,7 @@ jobs: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer xcodebuild -version > CACHE_KEY.txt + brew list --versions >> CACHE_KEY.txt echo $MANUAL_CACHING >> CACHE_KEY.txt echo "$GITHUB_WORKSPACE" >> CACHE_KEY.txt if [ "$AUTO_CACHING" = "1" ]; then From 333ef9b48ab0c3a009c0039775eb69ad189f62ad Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Fri, 12 Jan 2024 07:15:32 +0400 Subject: [PATCH 15/73] Hide connection widget when the window is not exposed --- .../view/history_view_top_bar_widget.cpp | 14 ++++++++++- .../window/window_connecting_widget.cpp | 23 ++++++++++++++----- .../window/window_connecting_widget.h | 2 ++ 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 774081836d..bb3407afd5 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -55,6 +55,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_send_action.h" #include "chat_helpers/emoji_interactions.h" #include "base/unixtime.h" +#include "base/event_filter.h" #include "support/support_helper.h" #include "apiwrap.h" #include "api/api_chat_participants.h" @@ -230,6 +231,16 @@ TopBarWidget::TopBarWidget( updateConnectingState(); }, lifetime()); + base::install_event_filter( + this, + window()->windowHandle(), + [=](not_null e) { + if (e->type() == QEvent::Expose) { + updateConnectingState(); + } + return base::EventFilterResult::Continue; + }); + setCursor(style::cur_pointer); } @@ -241,7 +252,8 @@ Main::Session &TopBarWidget::session() const { void TopBarWidget::updateConnectingState() { const auto state = _controller->session().mtp().dcstate(); - if (state == MTP::ConnectedState) { + const auto exposed = window()->windowHandle()->isExposed(); + if (state == MTP::ConnectedState || !exposed) { if (_connecting) { _connecting = nullptr; update(); diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index 3d3a5d2a34..d045b153c4 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -7,6 +7,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #include "window/window_connecting_widget.h" +#include "base/event_filter.h" #include "ui/widgets/buttons.h" #include "ui/effects/radial_animation.h" #include "ui/painter.h" @@ -207,6 +208,14 @@ ConnectionState::ConnectionState( rpl::producer shown) : _account(account) , _parent(parent) +, _exposeFilter(base::install_event_filter( + parent->window()->windowHandle(), + [=](not_null e) { + if (e->type() == QEvent::Expose) { + refreshState(); + } + return base::EventFilterResult::Continue; + })) , _refreshTimer([=] { refreshState(); }) , _currentLayout(computeLayout(_state)) { rpl::combine( @@ -290,6 +299,7 @@ void ConnectionState::setBottomSkip(int skip) { void ConnectionState::refreshState() { using Checker = Core::UpdateChecker; const auto state = [&]() -> State { + const auto exposed = _parent->window()->windowHandle()->isExposed(); const auto under = _widget && _widget->isOver(); const auto ready = (Checker().state() == Checker::State::Ready); const auto state = _account->mtp().dcstate(); @@ -297,18 +307,18 @@ void ConnectionState::refreshState() { if (state == MTP::ConnectingState || state == MTP::DisconnectedState || (state < 0 && state > -600)) { - return { State::Type::Connecting, proxy, under, ready }; + return { State::Type::Connecting, proxy, exposed, under, ready }; } else if (state < 0 && state >= -kMinimalWaitingStateDuration && _state.type != State::Type::Waiting) { - return { State::Type::Connecting, proxy, under, ready }; + return { State::Type::Connecting, proxy, exposed, under, ready }; } else if (state < 0) { const auto wait = ((-state) / 1000) + 1; - return { State::Type::Waiting, proxy, under, ready, wait }; + return { State::Type::Waiting, proxy, exposed, under, ready, wait }; } - return { State::Type::Connected, proxy, under, ready }; + return { State::Type::Connected, proxy, exposed, under, ready }; }(); - if (state.waitTillRetry > 0) { + if (state.exposed && state.waitTillRetry > 0) { _refreshTimer.callOnce(kRefreshTimeout); } if (state == _state) { @@ -421,7 +431,8 @@ auto ConnectionState::computeLayout(const State &state) const -> Layout { auto result = Layout(); result.proxyEnabled = state.useProxy; result.progressShown = (state.type != State::Type::Connected); - result.visible = !state.updateReady + result.visible = state.exposed + && !state.updateReady && (state.useProxy || state.type == State::Type::Connecting || state.type == State::Type::Waiting); diff --git a/Telegram/SourceFiles/window/window_connecting_widget.h b/Telegram/SourceFiles/window/window_connecting_widget.h index 5c391a9a6e..7813ce5ad1 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.h +++ b/Telegram/SourceFiles/window/window_connecting_widget.h @@ -46,6 +46,7 @@ private: }; Type type = Type::Connected; bool useProxy = false; + bool exposed = false; bool underCursor = false; bool updateReady = false; int waitTillRetry = 0; @@ -79,6 +80,7 @@ private: const not_null _account; not_null _parent; + base::unique_qptr _exposeFilter; rpl::variable _bottomSkip; base::unique_qptr _widget; bool _forceHidden = false; From eca8c28dea1c59dc6ea5f48bd83fb3f06c4b2b8d Mon Sep 17 00:00:00 2001 From: Ilya Fedin Date: Sat, 13 Jan 2024 00:50:29 +0400 Subject: [PATCH 16/73] Add missing QWindow includes --- .../SourceFiles/history/view/history_view_top_bar_widget.cpp | 2 ++ Telegram/SourceFiles/window/window_connecting_widget.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index bb3407afd5..891f45927a 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -65,6 +65,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_info.h" #include "styles/style_menu_icons.h" +#include + namespace HistoryView { namespace { diff --git a/Telegram/SourceFiles/window/window_connecting_widget.cpp b/Telegram/SourceFiles/window/window_connecting_widget.cpp index d045b153c4..7a757df68a 100644 --- a/Telegram/SourceFiles/window/window_connecting_widget.cpp +++ b/Telegram/SourceFiles/window/window_connecting_widget.cpp @@ -23,6 +23,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "lang/lang_keys.h" #include "styles/style_window.h" +#include + namespace Window { namespace { From dd1cca1a0ae880939242762de06e3d53d82440cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:58:13 +0000 Subject: [PATCH 17/73] Bump jinja2 from 3.1.2 to 3.1.3 in /Telegram/build/docker/centos_env Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3) --- updated-dependencies: - dependency-name: jinja2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Telegram/build/docker/centos_env/poetry.lock | 28 +++++++++---------- .../build/docker/centos_env/pyproject.toml | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Telegram/build/docker/centos_env/poetry.lock b/Telegram/build/docker/centos_env/poetry.lock index 3b86e84d50..08526811d4 100644 --- a/Telegram/build/docker/centos_env/poetry.lock +++ b/Telegram/build/docker/centos_env/poetry.lock @@ -1,10 +1,15 @@ +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. + [[package]] name = "jinja2" -version = "3.1.2" +version = "3.1.3" description = "A very fast and expressive template engine." -category = "main" optional = false python-versions = ">=3.7" +files = [ + {file = "Jinja2-3.1.3-py3-none-any.whl", hash = "sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa"}, + {file = "Jinja2-3.1.3.tar.gz", hash = "sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90"}, +] [package.dependencies] MarkupSafe = ">=2.0" @@ -16,21 +21,9 @@ i18n = ["Babel (>=2.7)"] name = "markupsafe" version = "2.1.1" description = "Safely add untrusted strings to HTML/XML markup." -category = "main" optional = false python-versions = ">=3.7" - -[metadata] -lock-version = "1.1" -python-versions = "^3.7" -content-hash = "fdf86553de6f950425c8ca77fe37127c9242c83445ce44b951ee4032ef72ea2f" - -[metadata.files] -jinja2 = [ - {file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"}, - {file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"}, -] -markupsafe = [ +files = [ {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:86b1f75c4e7c2ac2ccdaec2b9022845dbb81880ca318bb7a0a01fbf7813e3812"}, {file = "MarkupSafe-2.1.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:f121a1420d4e173a5d96e47e9a0c0dcff965afdf1626d28de1460815f7c4ee7a"}, {file = "MarkupSafe-2.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a49907dd8420c5685cfa064a1335b6754b74541bbb3706c259c02ed65b644b3e"}, @@ -72,3 +65,8 @@ markupsafe = [ {file = "MarkupSafe-2.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:46d00d6cfecdde84d40e572d63735ef81423ad31184100411e6e3388d405e247"}, {file = "MarkupSafe-2.1.1.tar.gz", hash = "sha256:7f91197cc9e48f989d12e4e6fbc46495c446636dfc81b9ccf50bb0ec74b91d4b"}, ] + +[metadata] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "bac9a23a86839c72127e75f2cf181e331f59d96f723403d529e7ea19774ff9c4" diff --git a/Telegram/build/docker/centos_env/pyproject.toml b/Telegram/build/docker/centos_env/pyproject.toml index b6507ba3f3..bba5c212f1 100644 --- a/Telegram/build/docker/centos_env/pyproject.toml +++ b/Telegram/build/docker/centos_env/pyproject.toml @@ -6,7 +6,7 @@ authors = [] [tool.poetry.dependencies] python = "^3.7" -Jinja2 = "^3.1.2" +Jinja2 = "^3.1.3" [tool.poetry.dev-dependencies] From 0faf801de7853ff7a3270e6e4bf3ce23c255d6b7 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 3 Jan 2024 14:46:34 +0400 Subject: [PATCH 18/73] Update API scheme to layer 171. --- Telegram/SourceFiles/api/api_messages_search.cpp | 1 + .../SourceFiles/calls/calls_box_controller.cpp | 1 + .../SourceFiles/data/data_search_controller.cpp | 1 + Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 3 +++ Telegram/SourceFiles/export/export_api_wrap.cpp | 1 + Telegram/SourceFiles/mtproto/scheme/api.tl | 15 ++++++++++++--- 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/api/api_messages_search.cpp b/Telegram/SourceFiles/api/api_messages_search.cpp index 15119b9068..cc97e22c0b 100644 --- a/Telegram/SourceFiles/api/api_messages_search.cpp +++ b/Telegram/SourceFiles/api/api_messages_search.cpp @@ -91,6 +91,7 @@ void MessagesSearch::searchRequest() { ? _from->input : MTP_inputPeerEmpty()), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTPint(), // top_msg_id MTP_inputMessagesFilterEmpty(), MTP_int(0), // min_date diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 9eb53580f6..11c6347d5d 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -521,6 +521,7 @@ void BoxController::loadMoreRows() { MTP_string(), // q MTP_inputPeerEmpty(), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTPint(), // top_msg_id MTP_inputMessagesFilterPhoneCalls(MTP_flags(0)), MTP_int(0), // min_date diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp index 688ce4ae98..43c5efb66d 100644 --- a/Telegram/SourceFiles/data/data_search_controller.cpp +++ b/Telegram/SourceFiles/data/data_search_controller.cpp @@ -98,6 +98,7 @@ std::optional PrepareSearchRequest( MTP_string(query), MTP_inputPeerEmpty(), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTP_int(topicRootId), filter, MTP_int(0), // min_date diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 4aa36ec385..f6ace227ad 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -1764,6 +1764,7 @@ bool Widget::searchMessages(bool searchCache) { ? _searchQueryFrom->input : MTP_inputPeerEmpty()), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTP_int(topic ? topic->rootId() : 0), MTP_inputMessagesFilterEmpty(), MTP_int(0), // min_date @@ -2006,6 +2007,7 @@ void Widget::searchMore() { ? _searchQueryFrom->input : MTP_inputPeerEmpty()), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTP_int(topic ? topic->rootId() : 0), MTP_inputMessagesFilterEmpty(), MTP_int(0), // min_date @@ -2079,6 +2081,7 @@ void Widget::searchMore() { ? _searchQueryFrom->input : MTP_inputPeerEmpty()), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTPint(), // top_msg_id MTP_inputMessagesFilterEmpty(), MTP_int(0), // min_date diff --git a/Telegram/SourceFiles/export/export_api_wrap.cpp b/Telegram/SourceFiles/export/export_api_wrap.cpp index 61f29b16c2..25fe29a716 100644 --- a/Telegram/SourceFiles/export/export_api_wrap.cpp +++ b/Telegram/SourceFiles/export/export_api_wrap.cpp @@ -1625,6 +1625,7 @@ void ApiWrap::requestChatMessages( MTP_string(), // query MTP_inputPeerSelf(), MTPInputPeer(), // saved_peer_id + MTPVector(), // saved_reaction MTPint(), // top_msg_id MTP_inputMessagesFilterEmpty(), MTP_int(0), // min_date diff --git a/Telegram/SourceFiles/mtproto/scheme/api.tl b/Telegram/SourceFiles/mtproto/scheme/api.tl index 87ce36bbc9..fee427f9f0 100644 --- a/Telegram/SourceFiles/mtproto/scheme/api.tl +++ b/Telegram/SourceFiles/mtproto/scheme/api.tl @@ -400,6 +400,7 @@ updateBotMessageReaction#ac21d3ce peer:Peer msg_id:int date:int actor:Peer old_r updateBotMessageReactions#9cb7759 peer:Peer msg_id:int date:int reactions:Vector qts:int = Update; updateSavedDialogPinned#aeaf9e74 flags:# pinned:flags.0?true peer:DialogPeer = Update; updatePinnedSavedDialogs#686c85a6 flags:# order:flags.0?Vector = Update; +updateSavedReactionTags#39c67432 = Update; updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State; @@ -1366,7 +1367,7 @@ auth.loggedOut#c3a2835f flags:# future_auth_token:flags.0?bytes = auth.LoggedOut reactionCount#a3d1cb80 flags:# chosen_order:flags.0?int reaction:Reaction count:int = ReactionCount; -messageReactions#4f2b9479 flags:# min:flags.0?true can_see_list:flags.2?true results:Vector recent_reactions:flags.1?Vector = MessageReactions; +messageReactions#4f2b9479 flags:# min:flags.0?true can_see_list:flags.2?true reactions_as_tags:flags.3?true results:Vector recent_reactions:flags.1?Vector = MessageReactions; messages.messageReactionsList#31bd492d flags:# count:int reactions:Vector chats:Vector users:Vector next_offset:flags.0?string = messages.MessageReactionsList; @@ -1643,6 +1644,11 @@ messages.savedDialogs#f83ae221 dialogs:Vector messages:Vector messages:Vector chats:Vector users:Vector = messages.SavedDialogs; messages.savedDialogsNotModified#c01f6fe8 count:int = messages.SavedDialogs; +savedReactionTag#cb6ff828 flags:# reaction:Reaction title:flags.0?string count:int = SavedReactionTag; + +messages.savedReactionTagsNotModified#889b59ef = messages.SavedReactionTags; +messages.savedReactionTags#3259950a tags:Vector hash:long = messages.SavedReactionTags; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1802,7 +1808,7 @@ contacts.setBlocked#94c65c76 flags:# my_stories_from:flags.0?true id:Vector = messages.Messages; messages.getDialogs#a0f4cb4f flags:# exclude_pinned:flags.0?true folder_id:flags.1?int offset_date:int offset_id:int offset_peer:InputPeer limit:int hash:long = messages.Dialogs; messages.getHistory#4423e6c5 peer:InputPeer offset_id:int offset_date:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; -messages.search#a7b4e929 flags:# peer:InputPeer q:string from_id:flags.0?InputPeer saved_peer_id:flags.2?InputPeer top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; +messages.search#29ee847a flags:# peer:InputPeer q:string from_id:flags.0?InputPeer saved_peer_id:flags.2?InputPeer saved_reaction:flags.3?Vector top_msg_id:flags.1?int filter:MessagesFilter min_date:int max_date:int offset_id:int add_offset:int limit:int max_id:int min_id:int hash:long = messages.Messages; messages.readHistory#e306d3a peer:InputPeer max_id:int = messages.AffectedMessages; messages.deleteHistory#b08f922a flags:# just_clear:flags.0?true revoke:flags.1?true peer:InputPeer max_id:int min_date:flags.2?int max_date:flags.3?int = messages.AffectedHistory; messages.deleteMessages#e58e95d2 flags:# revoke:flags.0?true id:Vector = messages.AffectedMessages; @@ -1993,6 +1999,9 @@ messages.deleteSavedHistory#6e98102b flags:# peer:InputPeer max_id:int min_date: messages.getPinnedSavedDialogs#d63d94e0 = messages.SavedDialogs; messages.toggleSavedDialogPin#ac81bbde flags:# pinned:flags.0?true peer:InputDialogPeer = Bool; messages.reorderPinnedSavedDialogs#8b716587 flags:# force:flags.0?true order:Vector = Bool; +messages.getSavedReactionTags#761ddacf hash:long = messages.SavedReactionTags; +messages.updateSavedReactionTag#60297dec flags:# reaction:Reaction title:flags.0?string = Bool; +messages.getDefaultTagReactions#bdf93428 hash:long = messages.Reactions; updates.getState#edd4882a = updates.State; updates.getDifference#19c2f763 flags:# pts:int pts_limit:flags.1?int pts_total_limit:flags.0?int date:int qts:int qts_limit:flags.2?int = updates.Difference; @@ -2235,4 +2244,4 @@ premium.applyBoost#6b7da746 flags:# slots:flags.0?Vector peer:InputPeer = p premium.getBoostsStatus#42f1f61 peer:InputPeer = premium.BoostsStatus; premium.getUserBoosts#39854d1f peer:InputPeer user_id:InputUser = premium.BoostsList; -// LAYER 170 +// LAYER 171 From 9b43d204e2c8fe2e471edb73ba5a9986eb4bd174 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 3 Jan 2024 14:46:50 +0400 Subject: [PATCH 19/73] Track and render reactions as tags in Saved Messages. --- .../SourceFiles/data/data_saved_messages.cpp | 4 +- Telegram/SourceFiles/data/data_types.h | 2 + Telegram/SourceFiles/history/history_item.cpp | 57 +++--- Telegram/SourceFiles/history/history_item.h | 1 + .../history/view/history_view_message.cpp | 6 +- .../view/reactions/history_view_reactions.cpp | 166 ++++++++++++++++-- .../view/reactions/history_view_reactions.h | 11 ++ Telegram/SourceFiles/ui/chat/chat.style | 6 + Telegram/SourceFiles/ui/empty_userpic.cpp | 2 +- 9 files changed, 216 insertions(+), 39 deletions(-) diff --git a/Telegram/SourceFiles/data/data_saved_messages.cpp b/Telegram/SourceFiles/data/data_saved_messages.cpp index 66bc87609b..d81f97fe59 100644 --- a/Telegram/SourceFiles/data/data_saved_messages.cpp +++ b/Telegram/SourceFiles/data/data_saved_messages.cpp @@ -20,6 +20,8 @@ namespace { constexpr auto kPerPage = 50; constexpr auto kFirstPerPage = 10; +constexpr auto kListPerPage = 100; +constexpr auto kListFirstPerPage = 20; } // namespace @@ -82,7 +84,7 @@ void SavedMessages::sendLoadMore() { MTP_int(_offsetDate), MTP_int(_offsetId), _offsetPeer ? _offsetPeer->input : MTP_inputPeerEmpty(), - MTP_int(kPerPage), + MTP_int(_offsetId ? kListPerPage : kListFirstPerPage), MTP_long(0)) // hash ).done([=](const MTPmessages_SavedDialogs &result) { apply(result, false); diff --git a/Telegram/SourceFiles/data/data_types.h b/Telegram/SourceFiles/data/data_types.h index 31c976859e..46f75419ac 100644 --- a/Telegram/SourceFiles/data/data_types.h +++ b/Telegram/SourceFiles/data/data_types.h @@ -313,6 +313,8 @@ enum class MessageFlag : uint64 { ShowSimilarChannels = (1ULL << 41), Sponsored = (1ULL << 42), + + ReactionsAreTags = (1ULL << 43), }; inline constexpr bool is_flag_type(MessageFlag) { return true; } using MessageFlags = base::flags; diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index dcdd8b3d0e..35a2dc7db8 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -2429,6 +2429,10 @@ const std::vector &HistoryItem::reactions() const { return _reactions ? _reactions->list() : kEmpty; } +bool HistoryItem::reactionsAreTags() const { + return _flags & MessageFlag::ReactionsAreTags; +} + auto HistoryItem::recentReactions() const -> const base::flat_map< Data::ReactionId, @@ -3556,31 +3560,40 @@ bool HistoryItem::changeReactions(const MTPMessageReactions *reactions) { } if (!reactions) { _flags &= ~MessageFlag::CanViewReactions; + if (_history->peer->isSelf()) { + _flags |= MessageFlag::ReactionsAreTags; + } return (base::take(_reactions) != nullptr); } - return reactions->match([&](const MTPDmessageReactions &data) { - if (data.is_can_see_list()) { - _flags |= MessageFlag::CanViewReactions; - } else { - _flags &= ~MessageFlag::CanViewReactions; + const auto &data = reactions->data(); + const auto empty = data.vresults().v.isEmpty(); + if (data.is_reactions_as_tags() + || (empty && _history->peer->isSelf())) { + _flags |= MessageFlag::ReactionsAreTags; + } else { + _flags &= ~MessageFlag::ReactionsAreTags; + } + if (data.is_can_see_list()) { + _flags |= MessageFlag::CanViewReactions; + } else { + _flags &= ~MessageFlag::CanViewReactions; + } + if (empty) { + return (base::take(_reactions) != nullptr); + } else if (!_reactions) { + _reactions = std::make_unique(this); + } + const auto min = data.is_min(); + const auto &list = data.vresults().v; + const auto &recent = data.vrecent_reactions().value_or_empty(); + if (min && hasUnreadReaction()) { + // We can't update reactions from min if we have unread. + if (_reactions->checkIfChanged(list, recent, min)) { + updateReactionsUnknown(); } - if (data.vresults().v.isEmpty()) { - return (base::take(_reactions) != nullptr); - } else if (!_reactions) { - _reactions = std::make_unique(this); - } - const auto min = data.is_min(); - const auto &list = data.vresults().v; - const auto &recent = data.vrecent_reactions().value_or_empty(); - if (min && hasUnreadReaction()) { - // We can't update reactions from min if we have unread. - if (_reactions->checkIfChanged(list, recent, min)) { - updateReactionsUnknown(); - } - return false; - } - return _reactions->change(list, recent, min); - }); + return false; + } + return _reactions->change(list, recent, min); } void HistoryItem::applyTTL(const MTPDmessage &data) { diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 412b9e057c..75705eab88 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -454,6 +454,7 @@ public: not_null from) const; [[nodiscard]] crl::time lastReactionsRefreshTime() const; + [[nodiscard]] bool reactionsAreTags() const; [[nodiscard]] bool hasDirectLink() const; [[nodiscard]] bool changesWallPaper() const; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 4edffbe37e..f319dfc9a3 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -2917,8 +2917,12 @@ bool Message::isSignedAuthorElided() const { bool Message::embedReactionsInBottomInfo() const { const auto item = data(); const auto user = item->history()->peer->asUser(); - if (!user || user->isPremium() || user->session().premium()) { + if (!user + || user->isPremium() + || user->isSelf() + || user->session().premium()) { // Only in messages of a non premium user with a non premium user. + // In saved messages we use reactions for tags, we don't embed them. return false; } auto seenMy = false; diff --git a/Telegram/SourceFiles/history/view/reactions/history_view_reactions.cpp b/Telegram/SourceFiles/history/view/reactions/history_view_reactions.cpp index 9114725601..a7e83c0291 100644 --- a/Telegram/SourceFiles/history/view/reactions/history_view_reactions.cpp +++ b/Telegram/SourceFiles/history/view/reactions/history_view_reactions.cpp @@ -55,6 +55,7 @@ struct InlineList::Button { int count = 0; int countTextWidth = 0; bool chosen = false; + bool tag = false; }; InlineList::InlineList( @@ -118,6 +119,7 @@ void InlineList::layoutButtons() { ) | ranges::views::transform([](const MessageReaction &reaction) { return not_null{ &reaction }; }) | ranges::to_vector; + const auto tags = _data.flags & Data::Flag::Tags; const auto &list = _owner->list(::Data::Reactions::Type::All); ranges::sort(sorted, [&]( not_null a, @@ -142,8 +144,10 @@ void InlineList::layoutButtons() { buttons.push_back((i != end(_buttons)) ? std::move(*i) : prepareButtonWithId(id)); - const auto j = _data.recent.find(id); - if (j != end(_data.recent) && !j->second.empty()) { + if (tags) { + setButtonTag(buttons.back()); + } else if (const auto j = _data.recent.find(id) + ; j != end(_data.recent) && !j->second.empty()) { setButtonUserpics(buttons.back(), j->second); } else { setButtonCount(buttons.back(), reaction->count); @@ -168,12 +172,22 @@ InlineList::Button InlineList::prepareButtonWithId(const ReactionId &id) { return result; } +void InlineList::setButtonTag(Button &button) { + if (button.tag) { + return; + } + button.userpics = nullptr; + button.count = 0; + button.tag = true; +} + void InlineList::setButtonCount(Button &button, int count) { - if (button.count == count && !button.userpics) { + if (!button.tag && button.count == count && !button.userpics) { return; } button.userpics = nullptr; button.count = count; + button.tag = false; button.countText = Lang::FormatCountToShort(count).string; button.countTextWidth = st::semiboldFont->width(button.countText); } @@ -181,6 +195,7 @@ void InlineList::setButtonCount(Button &button, int count) { void InlineList::setButtonUserpics( Button &button, const std::vector> &peers) { + button.tag = false; if (!button.userpics) { button.userpics = std::make_unique(); } @@ -228,6 +243,10 @@ QSize InlineList::countOptimalSize() { const auto between = st::reactionInlineBetween; const auto padding = st::reactionInlinePadding; const auto size = st::reactionInlineSize; + const auto widthBaseTag = padding.left() + + size + + st::reactionInlineTagSkip + + padding.right(); const auto widthBaseCount = padding.left() + size + st::reactionInlineSkip @@ -245,7 +264,9 @@ QSize InlineList::countOptimalSize() { }; const auto height = padding.top() + size + padding.bottom(); for (auto &button : _buttons) { - const auto width = button.userpics + const auto width = button.tag + ? widthBaseTag + : button.userpics ? (widthBaseUserpics + userpicsWidth(button)) : (widthBaseCount + button.countTextWidth); button.geometry.setSize({ width, height }); @@ -336,7 +357,8 @@ void InlineList::paint( const auto padding = st::reactionInlinePadding; const auto size = st::reactionInlineSize; const auto skip = (size - st::reactionInlineImage) / 2; - const auto inbubble = (_data.flags & InlineListData::Flag::InBubble); + const auto tags = (_data.flags & Data::Flag::Tags); + const auto inbubble = (_data.flags & Data::Flag::InBubble); const auto flipped = (_data.flags & Data::Flag::Flipped); p.setFont(st::semiboldFont); for (const auto &button : _buttons) { @@ -366,21 +388,26 @@ void InlineList::paint( if (bubbleProgress > 0.) { auto hq = PainterHighQualityEnabler(p); p.setPen(Qt::NoPen); + auto opacity = 1.; + auto color = QColor(); if (inbubble) { if (!chosen) { - p.setOpacity(bubbleProgress * (context.outbg + opacity = bubbleProgress * (context.outbg ? kOutNonChosenOpacity - : kInNonChosenOpacity)); + : kInNonChosenOpacity); } else if (!bubbleReady) { - p.setOpacity(bubbleProgress); + opacity = bubbleProgress; } - p.setBrush(stm->msgFileBg); + color = stm->msgFileBg->c; } else { if (!bubbleReady) { - p.setOpacity(bubbleProgress); + opacity = bubbleProgress; } - p.setBrush(chosen ? st->msgServiceFg() : st->msgServiceBg()); + color = (chosen + ? st->msgServiceFg() + : st->msgServiceBg())->c; } + const auto radius = geometry.height() / 2.; const auto fill = geometry.marginsAdded({ flipped ? bubbleSkip : 0, @@ -388,7 +415,7 @@ void InlineList::paint( flipped ? 0 : bubbleSkip, 0, }); - p.drawRoundedRect(fill, radius, radius); + paintSingleBg(p, fill, color, opacity); if (inbubble && !chosen) { p.setOpacity(bubbleProgress); } @@ -434,7 +461,8 @@ void InlineList::paint( .target = image, }); } - if (bubbleProgress == 0.) { + if (tags || bubbleProgress == 0.) { + p.setOpacity(1.); continue; } resolveUserpicsImage(button); @@ -479,6 +507,115 @@ void InlineList::paint( } } +void InlineList::validateTagBg(const QColor &color) const { + if (!_tagBg.isNull() && _tagBgColor == color) { + return; + } + _tagBgColor = color; + + const auto padding = st::reactionInlinePadding; + const auto size = st::reactionInlineSize; + const auto width = padding.left() + + size + + st::reactionInlineTagSkip + + padding.right(); + const auto height = padding.top() + size + padding.bottom(); + const auto ratio = style::DevicePixelRatio(); + + auto mask = QImage( + QSize(width, height) * ratio, + QImage::Format_ARGB32_Premultiplied); + mask.setDevicePixelRatio(ratio); + + mask.fill(Qt::transparent); + auto p = QPainter(&mask); + + auto path = QPainterPath(); + const auto arrow = st::reactionInlineTagArrow; + const auto rradius = st::reactionInlineTagRightRadius * 1.; + const auto radius = st::reactionInlineTagLeftRadius - rradius; + const auto fg = QColor(255, 255, 255); + auto pen = QPen(fg); + pen.setWidthF(rradius * 2.); + pen.setJoinStyle(Qt::RoundJoin); + const auto rect = QRectF(0, 0, width, height).marginsRemoved( + { rradius, rradius, rradius, rradius }); + + const auto right = rect.x() + rect.width(); + const auto bottom = rect.y() + rect.height(); + path.moveTo(rect.x() + radius, rect.y()); + path.lineTo(right - arrow, rect.y()); + path.lineTo(right, rect.y() + rect.height() / 2); + path.lineTo(right - arrow, bottom); + path.lineTo(rect.x() + radius, bottom); + path.arcTo(QRectF(rect.x(), bottom - radius * 2, radius * 2, radius * 2), 270, -90); + path.lineTo(rect.x(), rect.y() + radius); + path.arcTo(QRectF(rect.x(), rect.y(), radius * 2, radius * 2), 180, -90); + path.closeSubpath(); + + const auto dsize = st::reactionInlineTagDot; + const auto dot = QRectF( + right - st::reactionInlineTagDotSkip - dsize, + rect.y() + (rect.height() - dsize) / 2., + dsize, + dsize); + + auto hq = PainterHighQualityEnabler(p); + p.setCompositionMode(QPainter::CompositionMode_Source); + p.setPen(pen); + p.setBrush(fg); + p.drawPath(path); + + p.setPen(Qt::NoPen); + p.setBrush(QColor(255, 255, 255, 255 * 0.6)); + p.drawEllipse(dot); + + p.end(); + + _tagBg = style::colorizeImage(mask, color); +} + +void InlineList::paintSingleBg( + Painter &p, + const QRect &fill, + const QColor &color, + float64 opacity) const { + p.setOpacity(opacity); + if (!(_data.flags & Data::Flag::Tags)) { + const auto radius = fill.height() / 2.; + p.setBrush(color); + p.drawRoundedRect(fill, radius, radius); + return; + } + validateTagBg(color); + const auto ratio = style::DevicePixelRatio(); + const auto left = st::reactionInlineTagLeftRadius; + const auto right = (_tagBg.width() / ratio) - left; + Assert(right > 0); + const auto useLeft = std::min(fill.width(), left); + p.drawImage( + QRect(fill.x(), fill.y(), useLeft, fill.height()), + _tagBg, + QRect(0, 0, useLeft * ratio, _tagBg.height())); + const auto middle = fill.width() - left - right; + if (middle > 0) { + p.fillRect(fill.x() + left, fill.y(), middle, fill.height(), color); + } + if (const auto useRight = fill.width() - left; useRight > 0) { + p.drawImage( + QRect( + fill.x() + fill.width() - useRight, + fill.y(), + useRight, + fill.height()), + _tagBg, + QRect(_tagBg.width() - useRight * ratio, + 0, + useRight * ratio, + _tagBg.height())); + } +} + bool InlineList::getState( QPoint point, not_null outResult) const { @@ -654,7 +791,8 @@ InlineListData InlineListDataFromMessage(not_null message) { } } result.flags = (message->hasOutLayout() ? Flag::OutLayout : Flag()) - | (message->embedReactionsInBubble() ? Flag::InBubble : Flag()); + | (message->embedReactionsInBubble() ? Flag::InBubble : Flag()) + | (item->reactionsAreTags() ? Flag::Tags : Flag()); return result; } diff --git a/Telegram/SourceFiles/history/view/reactions/history_view_reactions.h b/Telegram/SourceFiles/history/view/reactions/history_view_reactions.h index 398ec0cd80..cc4fa80d84 100644 --- a/Telegram/SourceFiles/history/view/reactions/history_view_reactions.h +++ b/Telegram/SourceFiles/history/view/reactions/history_view_reactions.h @@ -41,6 +41,7 @@ struct InlineListData { InBubble = 0x01, OutLayout = 0x02, Flipped = 0x04, + Tags = 0x08, }; friend inline constexpr bool is_flag_type(Flag) { return true; }; using Flags = base::flags; @@ -103,6 +104,7 @@ private: void layout(); void layoutButtons(); + void setButtonTag(Button &button); void setButtonCount(Button &button, int count); void setButtonUserpics( Button &button, @@ -115,6 +117,13 @@ private: QPoint innerTopLeft, const PaintContext &context, const QColor &textColor) const; + void paintSingleBg( + Painter &p, + const QRect &fill, + const QColor &color, + float64 opacity) const; + + void validateTagBg(const QColor &color) const; QSize countOptimalSize() override; @@ -124,6 +133,8 @@ private: Data _data; std::vector