diff --git a/Telegram/Resources/icons/ayu/burnt.png b/Telegram/Resources/icons/ayu/burnt.png new file mode 100755 index 0000000000..a46413a974 Binary files /dev/null and b/Telegram/Resources/icons/ayu/burnt.png differ diff --git a/Telegram/Resources/icons/ayu/burnt@2x.png b/Telegram/Resources/icons/ayu/burnt@2x.png new file mode 100755 index 0000000000..1f2cc1e059 Binary files /dev/null and b/Telegram/Resources/icons/ayu/burnt@2x.png differ diff --git a/Telegram/Resources/icons/ayu/burnt@3x.png b/Telegram/Resources/icons/ayu/burnt@3x.png new file mode 100755 index 0000000000..1a00b07e18 Binary files /dev/null and b/Telegram/Resources/icons/ayu/burnt@3x.png differ diff --git a/Telegram/SourceFiles/ayu/ui/ayu_icons.style b/Telegram/SourceFiles/ayu/ui/ayu_icons.style index 6fe6953a3f..4cd21b4c6a 100644 --- a/Telegram/SourceFiles/ayu/ui/ayu_icons.style +++ b/Telegram/SourceFiles/ayu/ui/ayu_icons.style @@ -47,6 +47,12 @@ deletedIcon: IconEmoji{ useIconColor: false; } +burntIcon: IconEmoji{ + icon: icon{{ "ayu/burnt", windowFg }}; + padding: margins(0px, 0px, 0px, 0px); + useIconColor: false; +} + dialogsExteraOfficialIcon: ThreeStateIcon { icon: icon {{ "ayu/dialogs_extera_official", dialogsVerifiedIconBg }}; over: icon {{ "ayu/dialogs_extera_official", dialogsVerifiedIconBgOver }}; diff --git a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp index 9861daf3e4..13910c458c 100644 --- a/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp +++ b/Telegram/SourceFiles/ayu/ui/context_menu/context_menu.cpp @@ -739,11 +739,7 @@ void AddRepeatMessageAction(not_null 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()