From bb33d0b997d0180a4f8f50a3cd52739266ce6e54 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 14 Jun 2024 15:32:02 +0300 Subject: [PATCH] Replaced credits currency with icon only in buttons with Buy type. --- .../history/history_item_components.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item_components.cpp b/Telegram/SourceFiles/history/history_item_components.cpp index dde906494..fd4ff1605 100644 --- a/Telegram/SourceFiles/history/history_item_components.cpp +++ b/Telegram/SourceFiles/history/history_item_components.cpp @@ -694,10 +694,20 @@ ReplyKeyboard::ReplyKeyboard( newRow.reserve(rowSize); for (auto j = 0; j != rowSize; ++j) { auto button = Button(); - const auto text = base::duplicate(row[j].text).replace( - Ui::kCreditsCurrency, - QChar(0x2B50)); + using Type = HistoryMessageMarkupButton::Type; + const auto isBuy = (row[j].type == Type::Buy); + static const auto RegExp = QRegularExpression("\\b" + + Ui::kCreditsCurrency + + "\\b"); + const auto text = isBuy + ? base::duplicate(row[j].text).replace( + RegExp, + QChar(0x2B50)) + : row[j].text; const auto textWithEntities = [&] { + if (!isBuy) { + return TextWithEntities(); + } auto result = TextWithEntities(); auto firstPart = true; for (const auto &part : text.split(QChar(0x2B50))) {