diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index ffbbc4d84..3f580d231 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -485,7 +485,7 @@ void History::destroyMessage(not_null item) { { if (!item->isService()) { - item->setPostAuthor(settings->deletedMark); + item->setAyuHint(settings->deletedMark); } else { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 13e52a6f7..dfc36d2c7 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -211,7 +211,7 @@ std::unique_ptr HistoryItem::CreateMedia( }); }, [&](const MTPDmessageMediaPhoto &media) -> Result { const auto photo = media.vphoto(); - if (media.vttl_seconds()) { + if (media.vttl_seconds() && false) { // AyuGram: show expiring messages LOG(("App Error: " "Unexpected MTPMessageMediaPhoto " "with ttl_seconds in CreateMedia.")); @@ -324,7 +324,7 @@ HistoryItem::HistoryItem( setServiceText({ tr::lng_message_empty(tr::now, Ui::Text::WithEntities) }); - } else if (checked == MediaCheckResult::HasTimeToLive) { + } else if (checked == MediaCheckResult::HasTimeToLive && false) { // AyuGram: show expiring messages createServiceFromMtp(data); applyTTL(data); } else if (checked == MediaCheckResult::HasStoryMention) { @@ -335,6 +335,22 @@ HistoryItem::HistoryItem( createComponents(data); if (const auto media = data.vmedia()) { setMedia(*media); + if (checked == MediaCheckResult::HasTimeToLive) { + media->match([&](const MTPDmessageMediaPhoto &media) { + auto time = media.vttl_seconds()->v; + setAyuHint("🕓 " + QString::number(time) + "s"); + }, [&](const MTPDmessageMediaDocument &media) { + auto time = media.vttl_seconds()->v; + setAyuHint("🕓 " + QString::number(time) + "s"); + }, [&](const MTPDmessageMediaWebPage &media) { + }, [&](const MTPDmessageMediaGame &media) { + }, [&](const MTPDmessageMediaInvoice &media) { + }, [&](const MTPDmessageMediaPoll &media) { + }, [&](const MTPDmessageMediaDice &media) { + }, [&](const MTPDmessageMediaStory &media) { + }, [&](const auto &) { + }); + } } auto textWithEntities = TextWithEntities{ qs(data.vmessage()), @@ -2477,12 +2493,6 @@ void HistoryItem::setForwardsCount(int count) { } void HistoryItem::setPostAuthor(const QString &author) { - const auto settings = &AyuSettings::getInstance(); - if (settings->saveDeletedMessages && !(_flags & MessageFlag::HasPostAuthor)) - { - _flags |= MessageFlag::HasPostAuthor; - } - auto msgsigned = Get(); if (author.isEmpty()) { if (!msgsigned) { @@ -2502,11 +2512,36 @@ void HistoryItem::setPostAuthor(const QString &author) { msgsigned->isAnonymousRank = !isDiscussionPost() && this->author()->isMegagroup(); - if (settings->saveDeletedMessages) + history()->owner().requestItemResize(this); +} + +void HistoryItem::setAyuHint(const QString &hint) { + const auto settings = &AyuSettings::getInstance(); + if (!(_flags & MessageFlag::HasPostAuthor)) { - history()->owner().requestItemViewRefresh(this); + _flags |= MessageFlag::HasPostAuthor; } + auto msgsigned = Get(); + if (hint.isEmpty()) { + if (!msgsigned) { + return; + } + RemoveComponents(HistoryMessageSigned::Bit()); + history()->owner().requestItemResize(this); + return; + } + if (!msgsigned) { + AddComponents(HistoryMessageSigned::Bit()); + msgsigned = Get(); + } else if (msgsigned->author == hint) { + return; + } + msgsigned->author = hint; + msgsigned->isAnonymousRank = !isDiscussionPost() + && this->author()->isMegagroup(); + + history()->owner().requestItemViewRefresh(this); history()->owner().requestItemResize(this); } diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index 1b15d91e8..54040551d 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -395,6 +395,7 @@ public: MsgId replyToTop, bool isForumPost); void setPostAuthor(const QString &author); + void setAyuHint(const QString &hint); void setRealId(MsgId newId); void incrementReplyToTopCounter();