From 14f937cb025f90d899429ffb48702d26cf421022 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 26 Aug 2022 10:13:42 +0400 Subject: [PATCH] Show only some reactions in the bottom info. Only in private chats with no premium users. Only if nobody sent more than one reaction while was premium. Only if nobody sent a custom emoji reaction while was premium. --- .../history/view/history_view_message.cpp | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 30982b8ff9..767e4e59dd 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -2167,7 +2167,34 @@ bool Message::isSignedAuthorElided() const { } bool Message::embedReactionsInBottomInfo() const { - return data()->history()->peer->isUser(); + const auto item = data(); + const auto user = item->history()->peer->asUser(); + if (!user || user->isPremium() || user->session().premium()) { + // Only in messages of a non premium user with a non premium user. + return false; + } + auto seenMy = false; + auto seenHis = false; + for (const auto &reaction : item->reactions()) { + if (reaction.id.custom()) { + // Only in messages without any custom emoji reactions. + return false; + } + // Only in messages without two reactions from the same person. + if (reaction.my) { + if (seenMy) { + return false; + } + seenMy = true; + } + if (!reaction.my || (reaction.count > 1)) { + if (seenHis) { + return false; + } + seenHis = true; + } + } + return true; } bool Message::embedReactionsInBubble() const {