From 0aa7e852284c20b40acb6512b6c7fd2844afd4e8 Mon Sep 17 00:00:00 2001 From: AlexeyZavar Date: Thu, 19 Mar 2026 00:12:45 +0300 Subject: [PATCH] feat: show burn status --- Telegram/Resources/icons/ayu/burnt.png | Bin 0 -> 360 bytes Telegram/Resources/icons/ayu/burnt@2x.png | Bin 0 -> 559 bytes Telegram/Resources/icons/ayu/burnt@3x.png | Bin 0 -> 791 bytes Telegram/SourceFiles/ayu/ui/ayu_icons.style | 6 +++ .../ayu/ui/context_menu/context_menu.cpp | 36 +++--------------- Telegram/SourceFiles/history/history_item.cpp | 8 ++++ Telegram/SourceFiles/history/history_item.h | 3 +- .../history/view/history_view_bottom_info.cpp | 22 +++++++++-- .../history/view/history_view_bottom_info.h | 1 + .../view/media/history_view_document.cpp | 2 +- 10 files changed, 43 insertions(+), 35 deletions(-) create mode 100755 Telegram/Resources/icons/ayu/burnt.png create mode 100755 Telegram/Resources/icons/ayu/burnt@2x.png create mode 100755 Telegram/Resources/icons/ayu/burnt@3x.png diff --git a/Telegram/Resources/icons/ayu/burnt.png b/Telegram/Resources/icons/ayu/burnt.png new file mode 100755 index 0000000000000000000000000000000000000000..a46413a974d96d4d4af99dd120dd65bab8345fe5 GIT binary patch literal 360 zcmeAS@N?(olHy`uVBq!ia0vp^B0wy`!3HFMdEYGqQk(@Ik;M!Q+`=Ht$S`Y;1W=H% zILO_JVcj{Imp~3nx}&cn1H;CC?mvmFKt5lIYeY$Kep*R+Vo@rCTV{H0;=GO1l7TXh zJzX3_Dj45RN#t!d5NPdBWtz~yqSC;uqQJ=Mae&dnfk|ir178&T_PEK>yYjZMXMRh* z>CJIr+WPnR7$q4LRIcy}X>*jUrAHVTSVS@%&$<}qNS)|IJ zcg=}o+Lqhx{%Y4dn}XYBJe`jOnEUVOo>tO~eby)Cv~Eh!w|VE37Tk|)3vSM+o3$+A zX8DIDTkCeNdoAU|lHgF5bHBXfWv=+Su2Wy0Ygm`*o!g*uIz8-N_nTvmy~4~t6Z2U5 zc@HNf*4~f*9b}gq6dGFKd+bWcuYdnP@c&_az#NuyXxZAR)`o3R&boA+m7D2nEz*EG%221WKBz__4%AUGpU)1?hg@6>735+CxmZCiR*;JoaXPy-j$;$u$002ovPDHLkV1l={>J9(^ literal 0 HcmV?d00001 diff --git a/Telegram/Resources/icons/ayu/burnt@3x.png b/Telegram/Resources/icons/ayu/burnt@3x.png new file mode 100755 index 0000000000000000000000000000000000000000..1a00b07e187bd309dea8b88e04267ddba6f54e13 GIT binary patch literal 791 zcmV+y1L*vTP)UO(N?~i+IlEQjZ@Q4QKro!gHK)A8seGn7XfHN+Z5_jJ0 zkk$yT#bWX6+HSYIhqnpI**077D-Ruy$26PGeqCQKmzno(HXG7Ev1tW@c_mo^U8VDvtuGjhoveQmbbmbbq()wGrlvyd7icnLsKJz zhDGUkM^|t%@t^xzThHX}h2eEYvHF5xSc?#j7SMLG>2odoEomYDR4~Vq{ux5CG?cyi zu&+e*rx3oF<~u>K?*zfV69oHC5bQfau menu, HistoryItem *item) { } void AddReadUntilAction(not_null menu, HistoryItem *item) { - if (item->isLocal() || item->isService() || item->out() || item->isDeleted()) { - return; - } - - if (item->history()->peer->isSelf()) { + if (item->isLocal() || item->out() || item->isDeleted() || item->history()->peer->isSelf()) { return; } @@ -754,11 +750,10 @@ void AddReadUntilAction(not_null menu, HistoryItem *item) { menu->addAction( tr::ayu_ReadUntilMenuText(tr::now), - [=]() + [=] { readHistory(item); - if (item->media() && item->media()->ttlSeconds() <= 0 && item->unsupportedTTL() <= 0 && !item->out() && item - ->isUnreadMedia()) { + if (item->media() && item->media()->ttlSeconds() <= 0 && item->unsupportedTTL() <= 0 && !item->out()) { const auto ids = MTP_vector(1, MTP_int(item->id)); if (const auto channel = item->history()->peer->asChannel()) { item->history()->session().api().request(MTPchannels_ReadMessageContents( @@ -789,38 +784,19 @@ void AddBurnAction(not_null menu, HistoryItem *item) { menu->addAction( tr::ayu_ExpireMediaContextMenuText(tr::now), - [=]() + [=] { const auto ids = MTP_vector(1, MTP_int(item->id)); - const auto callback = [=]() - { - if (const auto window = Core::App().activeWindow()) { - if (const auto controller = window->sessionController()) { - controller->showToast(tr::lng_box_ok(tr::now)); - } - } - }; - if (const auto channel = item->history()->peer->asChannel()) { - item->history()->session().api().request(MTPchannels_ReadMessageContents( - channel->inputChannel(), - ids - )).done([=]() - { - callback(); - }).send(); - } else { - item->history()->session().api().request(MTPmessages_ReadMessageContents( + item->history()->session().api().request(MTPmessages_ReadMessageContents( ids )).done([=](const MTPmessages_AffectedMessages &result) { item->history()->session().api().applyAffectedMessages( item->history()->peer, result); - callback(); + item->markContentsRead(); }).send(); - } - item->markContentsRead(); }, &st::menuIconTTLAny); } diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 03e69dd6b6..72a10bbd8b 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1677,6 +1677,10 @@ void HistoryItem::markMediaAndMentionRead() { } } } + + if (isBurnt()) { + _history->owner().notifyItemDataChange(this); + } } void HistoryItem::markReactionsRead() { @@ -3533,6 +3537,10 @@ bool HistoryItem::isDeleted() const { return _deleted; } +bool HistoryItem::isBurnt() const { + return ((media() && media()->ttlSeconds()) || unsupportedTTL()) && !isUnreadMedia(); +} + bool HistoryItem::wasDeletedAnimated() const { return _deletedAnimated; } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index cbf71ba551..d3661456a2 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -436,7 +436,8 @@ public: bool isForumPost); void setPostAuthor(const QString &author); void setDeleted(); - bool isDeleted() const; + [[nodiscard]] bool isDeleted() const; + [[nodiscard]] bool isBurnt() const; [[nodiscard]] bool wasDeletedAnimated() const; void markDeletedAnimated(); void applyTTL(TimeId destroyAt); diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp index dce5d25e62..163c5c6c85 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.cpp @@ -509,6 +509,10 @@ void BottomInfo::layoutDateText() { .textColor = false, })).append(" "); } + if (_data.flags & Data::Flag::AyuBurnt) { + marked.append(Ui::Text::IconEmoji(&st::burntIcon)); + marked.append(' '); + } marked.append(full); _authorEditedDate.setMarkedText( st::msgDateTextStyle, @@ -516,6 +520,15 @@ void BottomInfo::layoutDateText() { Ui::NameTextOptions(), helper.context()); } else { + TextWithEntities burnt; + if (_data.flags & Data::Flag::AyuBurnt) { + burnt = Ui::Text::IconEmoji(&st::burntIcon); + if (!(_data.flags & Data::Flag::AyuDeleted) + && !(_data.flags & Data::Flag::Edited)) { + burnt.append(' '); + } + } + TextWithEntities deleted; if (_data.flags & Data::Flag::AyuDeleted) { deleted = Ui::Text::IconEmoji(&st::deletedIcon); @@ -559,11 +572,11 @@ void BottomInfo::layoutDateText() { if (_data.flags & Data::Flag::Sponsored) { // ... } else if (_data.flags & Data::Flag::Imported) { - full.append(deleted).append(date).append(' ').append(tr::lng_imported(tr::now)); + full.append(burnt).append(deleted).append(date).append(' ').append(tr::lng_imported(tr::now)); } else if (name.isEmpty()) { - full.append(deleted).append(date); + full.append(burnt).append(deleted).append(date); } else { - full.append(deleted).append(name).append(afterAuthor); + full.append(burnt).append(deleted).append(name).append(afterAuthor); } auto helper = Ui::Text::CustomEmojiHelper( @@ -775,6 +788,9 @@ BottomInfo::Data BottomInfoDataFromMessage(not_null message) { if (item->isDeleted()) { result.flags |= Flag::AyuDeleted; } + if (item->isBurnt()) { + result.flags |= Flag::AyuBurnt; + } if (!forwarded) { return result; } diff --git a/Telegram/SourceFiles/history/view/history_view_bottom_info.h b/Telegram/SourceFiles/history/view/history_view_bottom_info.h index a76afb2df8..2a9b18d7bc 100644 --- a/Telegram/SourceFiles/history/view/history_view_bottom_info.h +++ b/Telegram/SourceFiles/history/view/history_view_bottom_info.h @@ -44,6 +44,7 @@ public: EstimateDate = 0x100, ForwardedDate = 0x200, AyuDeleted = 0x400, + AyuBurnt = 0x800, //Unread, // We don't want to pass and update it in Date for now. }; friend inline constexpr bool is_flag_type(Flag) { return true; }; diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index bcf954f21e..b940873a98 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -426,7 +426,7 @@ QSize Document::countOptimalSize() { const auto history = _realParent->history(); const auto session = &history->session(); const auto transcribes = &session->api().transcribes(); - if (_parent->data()->media()->ttlSeconds() + if ((_parent->data()->media() && _parent->data()->media()->ttlSeconds()) || _realParent->isScheduled() || _realParent->isAdminLogEntry() || (!session->premium()