fix: ttl messages hint

This commit is contained in:
AlexeyZavar 2025-03-09 01:28:07 +03:00
parent 277a2edb57
commit 7c940a0480

View file

@ -3095,7 +3095,12 @@ void HistoryItem::setDeleted() {
_deleted = true;
const auto settings = &AyuSettings::getInstance();
setAyuHint(settings->deletedMark);
if (settings->replaceBottomInfoWithIcons) {
history()->owner().requestItemViewRefresh(this);
history()->owner().requestItemResize(this);
} else {
setAyuHint(settings->deletedMark);
}
}
bool HistoryItem::isDeleted() const {
@ -3104,7 +3109,32 @@ bool HistoryItem::isDeleted() const {
void HistoryItem::setAyuHint(const QString &hint) {
try {
if (isService() && !_text.empty()) {
auto msgsigned = Get<HistoryMessageSigned>();
if (hint.isEmpty()) {
if (!msgsigned) {
return;
}
RemoveComponents(HistoryMessageSigned::Bit());
history()->owner().requestItemViewRefresh(this);
history()->owner().requestItemResize(this);
return;
}
if (!isService()) {
if (!(_flags & MessageFlag::HasPostAuthor)) {
_flags |= MessageFlag::HasPostAuthor;
}
if (!msgsigned) {
AddComponents(HistoryMessageSigned::Bit());
msgsigned = Get<HistoryMessageSigned>();
} else if (msgsigned->author == hint) {
return;
}
msgsigned->author = hint;
msgsigned->isAnonymousRank = !isDiscussionPost()
&& this->author()->isMegagroup();
} else if (/* isService() && */!_text.empty()) {
const auto data = Get<HistoryServiceData>();
const auto postfix = QString(" (%1)").arg(hint);
if (!_text.text.endsWith(postfix)) { // fix stacking for TTL messages
@ -3114,6 +3144,8 @@ void HistoryItem::setAyuHint(const QString &hint) {
};
setServiceText(std::move(prepared));
}
} else {
return;
}
// update bottom info