diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.cpp b/Telegram/SourceFiles/boxes/gift_premium_box.cpp index 95a4a73921..425e816af4 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.cpp +++ b/Telegram/SourceFiles/boxes/gift_premium_box.cpp @@ -96,6 +96,10 @@ constexpr auto kHorizontalBar = QChar(0x2015); return QString(); }; +[[nodiscard]] QString FixupTransactionId(QString origin) { + return origin.replace(kHorizontalBar, QChar('-')); +} + [[nodiscard]] Data::GiftCodeLink MakeGiftCodeLink( not_null session, const QString &slug) { @@ -1383,9 +1387,7 @@ void AddStarGiftTable( auto label = MakeMaybeMultilineTokenValue(table, address, st); label->setClickHandlerFilter([=](const auto &...) { TextUtilities::SetClipboardText( - TextForMimeData::Simple( - base::duplicate(address) - .replace(kHorizontalBar, QChar('-')))); + TextForMimeData::Simple(FixupTransactionId(address))); show->showToast( tr::lng_gift_unique_address_copied(tr::now)); return false; @@ -1810,9 +1812,7 @@ void AddCreditsHistoryEntryTable( auto label = MakeMaybeMultilineTokenValue(table, entry.id, st); label->setClickHandlerFilter([=](const auto &...) { TextUtilities::SetClipboardText( - TextForMimeData::Simple( - base::duplicate(entry.id) - .replace(kHorizontalBar, QChar('-')))); + TextForMimeData::Simple(FixupTransactionId(entry.id))); show->showToast( tr::lng_credits_box_history_entry_id_copied(tr::now)); return false; @@ -1987,3 +1987,29 @@ void AddCreditsBoostTable( rpl::single(Ui::Text::WithEntities(langDateTime(b.expiresAt)))); } } + +void AddChannelEarnTable( + std::shared_ptr show, + not_null container, + const Data::CreditsHistoryEntry &entry) { + const auto table = container->add( + object_ptr( + container, + st::giveawayGiftCodeTable), + st::giveawayGiftCodeTableMargin); + if (!entry.id.isEmpty()) { + auto label = MakeMaybeMultilineTokenValue(table, entry.id, {}); + label->setClickHandlerFilter([=](const auto &...) { + TextUtilities::SetClipboardText( + TextForMimeData::Simple(FixupTransactionId(entry.id))); + show->showToast( + tr::lng_credits_box_history_entry_id_copied(tr::now)); + return false; + }); + AddTableRow( + table, + tr::lng_credits_box_history_entry_id(), + std::move(label), + st::giveawayGiftCodeValueMargin); + } +} diff --git a/Telegram/SourceFiles/boxes/gift_premium_box.h b/Telegram/SourceFiles/boxes/gift_premium_box.h index ec3282e241..df0c17c1c1 100644 --- a/Telegram/SourceFiles/boxes/gift_premium_box.h +++ b/Telegram/SourceFiles/boxes/gift_premium_box.h @@ -34,6 +34,7 @@ struct CreditsEntryBoxStyleOverrides; } // namespace Settings namespace Ui { +class Show; class GenericBox; class VerticalLayout; } // namespace Ui @@ -100,3 +101,8 @@ void AddCreditsBoostTable( not_null container, Settings::CreditsEntryBoxStyleOverrides st, const Data::Boost &boost); + +void AddChannelEarnTable( + std::shared_ptr show, + not_null container, + const Data::CreditsHistoryEntry &entry); 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 63a687c54c..1563bef9dd 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 @@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "api/api_text_entities.h" #include "api/api_updates.h" #include "base/unixtime.h" +#include "boxes/gift_premium_box.h" #include "boxes/peers/edit_peer_color_box.h" // AddLevelBadge. #include "chat_helpers/stickers_emoji_pack.h" #include "core/application.h" @@ -1233,6 +1234,11 @@ void InnerWidget::fill() { st::channelEarnHistorySubLabel))); Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout()); + AddChannelEarnTable( + box->uiShow(), + box->verticalLayout(), + entry); + Ui::AddSkip(box->verticalLayout()); Ui::AddSkip(box->verticalLayout()); box->addRow(object_ptr>( box,