mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
feat: support expiring messages
This commit is contained in:
parent
d2f4a1b32c
commit
a67655a532
3 changed files with 47 additions and 11 deletions
|
@ -485,7 +485,7 @@ void History::destroyMessage(not_null<HistoryItem*> item) {
|
||||||
{
|
{
|
||||||
if (!item->isService())
|
if (!item->isService())
|
||||||
{
|
{
|
||||||
item->setPostAuthor(settings->deletedMark);
|
item->setAyuHint(settings->deletedMark);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -211,7 +211,7 @@ std::unique_ptr<Data::Media> HistoryItem::CreateMedia(
|
||||||
});
|
});
|
||||||
}, [&](const MTPDmessageMediaPhoto &media) -> Result {
|
}, [&](const MTPDmessageMediaPhoto &media) -> Result {
|
||||||
const auto photo = media.vphoto();
|
const auto photo = media.vphoto();
|
||||||
if (media.vttl_seconds()) {
|
if (media.vttl_seconds() && false) { // AyuGram: show expiring messages
|
||||||
LOG(("App Error: "
|
LOG(("App Error: "
|
||||||
"Unexpected MTPMessageMediaPhoto "
|
"Unexpected MTPMessageMediaPhoto "
|
||||||
"with ttl_seconds in CreateMedia."));
|
"with ttl_seconds in CreateMedia."));
|
||||||
|
@ -324,7 +324,7 @@ HistoryItem::HistoryItem(
|
||||||
setServiceText({
|
setServiceText({
|
||||||
tr::lng_message_empty(tr::now, Ui::Text::WithEntities)
|
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);
|
createServiceFromMtp(data);
|
||||||
applyTTL(data);
|
applyTTL(data);
|
||||||
} else if (checked == MediaCheckResult::HasStoryMention) {
|
} else if (checked == MediaCheckResult::HasStoryMention) {
|
||||||
|
@ -335,6 +335,22 @@ HistoryItem::HistoryItem(
|
||||||
createComponents(data);
|
createComponents(data);
|
||||||
if (const auto media = data.vmedia()) {
|
if (const auto media = data.vmedia()) {
|
||||||
setMedia(*media);
|
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{
|
auto textWithEntities = TextWithEntities{
|
||||||
qs(data.vmessage()),
|
qs(data.vmessage()),
|
||||||
|
@ -2477,12 +2493,6 @@ void HistoryItem::setForwardsCount(int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryItem::setPostAuthor(const QString &author) {
|
void HistoryItem::setPostAuthor(const QString &author) {
|
||||||
const auto settings = &AyuSettings::getInstance();
|
|
||||||
if (settings->saveDeletedMessages && !(_flags & MessageFlag::HasPostAuthor))
|
|
||||||
{
|
|
||||||
_flags |= MessageFlag::HasPostAuthor;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto msgsigned = Get<HistoryMessageSigned>();
|
auto msgsigned = Get<HistoryMessageSigned>();
|
||||||
if (author.isEmpty()) {
|
if (author.isEmpty()) {
|
||||||
if (!msgsigned) {
|
if (!msgsigned) {
|
||||||
|
@ -2502,11 +2512,36 @@ void HistoryItem::setPostAuthor(const QString &author) {
|
||||||
msgsigned->isAnonymousRank = !isDiscussionPost()
|
msgsigned->isAnonymousRank = !isDiscussionPost()
|
||||||
&& this->author()->isMegagroup();
|
&& 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<HistoryMessageSigned>();
|
||||||
|
if (hint.isEmpty()) {
|
||||||
|
if (!msgsigned) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RemoveComponents(HistoryMessageSigned::Bit());
|
||||||
|
history()->owner().requestItemResize(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!msgsigned) {
|
||||||
|
AddComponents(HistoryMessageSigned::Bit());
|
||||||
|
msgsigned = Get<HistoryMessageSigned>();
|
||||||
|
} else if (msgsigned->author == hint) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
msgsigned->author = hint;
|
||||||
|
msgsigned->isAnonymousRank = !isDiscussionPost()
|
||||||
|
&& this->author()->isMegagroup();
|
||||||
|
|
||||||
|
history()->owner().requestItemViewRefresh(this);
|
||||||
history()->owner().requestItemResize(this);
|
history()->owner().requestItemResize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -395,6 +395,7 @@ public:
|
||||||
MsgId replyToTop,
|
MsgId replyToTop,
|
||||||
bool isForumPost);
|
bool isForumPost);
|
||||||
void setPostAuthor(const QString &author);
|
void setPostAuthor(const QString &author);
|
||||||
|
void setAyuHint(const QString &hint);
|
||||||
void setRealId(MsgId newId);
|
void setRealId(MsgId newId);
|
||||||
void incrementReplyToTopCounter();
|
void incrementReplyToTopCounter();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue