[thanos] Broadcast item-about-to-destroy on TTL and clear paths too.

This commit is contained in:
23rd
2026-05-22 13:20:33 +03:00
parent f037e75ba0
commit 6c88a90d28
2 changed files with 46 additions and 6 deletions
+28 -4
View File
@@ -2882,8 +2882,18 @@ void Session::unregisterMessageTTL(
void Session::checkTTLs() {
_ttlCheckTimer.cancel();
const auto now = base::unixtime::now();
while (!_ttlMessages.empty() && _ttlMessages.begin()->first <= now) {
_ttlMessages.begin()->second.front()->destroy();
auto expired = std::vector<not_null<HistoryItem*>>();
for (const auto &[when, items] : _ttlMessages) {
if (when > now) {
break;
}
expired.insert(expired.end(), items.begin(), items.end());
}
if (!expired.empty()) {
notifyItemsAboutToBeDestroyed(expired);
for (const auto &item : expired) {
item->destroy();
}
}
scheduleNextTTLs();
}
@@ -2940,12 +2950,13 @@ void Session::processMessagesDeleted(
return;
}
auto toDestroy = std::vector<not_null<HistoryItem*>>();
auto historiesToCheck = base::flat_set<not_null<History*>>();
for (const auto &messageId : data) {
const auto i = list ? list->find(messageId.v) : Messages::iterator();
if (list && i != list->end()) {
const auto history = i->second->history();
i->second->destroy();
toDestroy.push_back(i->second);
if (!history->chatListMessageKnown()) {
historiesToCheck.emplace(history);
}
@@ -2953,22 +2964,35 @@ void Session::processMessagesDeleted(
affected->unknownMessageDeleted(messageId.v);
}
}
if (!toDestroy.empty()) {
notifyItemsAboutToBeDestroyed(toDestroy);
for (const auto &item : toDestroy) {
item->destroy();
}
}
for (const auto &history : historiesToCheck) {
history->requestChatListMessage();
}
}
void Session::processNonChannelMessagesDeleted(const QVector<MTPint> &data) {
auto toDestroy = std::vector<not_null<HistoryItem*>>();
auto historiesToCheck = base::flat_set<not_null<History*>>();
for (const auto &messageId : data) {
if (const auto item = nonChannelMessage(messageId.v)) {
const auto history = item->history();
item->destroy();
toDestroy.push_back(item);
if (!history->chatListMessageKnown()) {
historiesToCheck.emplace(history);
}
}
}
if (!toDestroy.empty()) {
notifyItemsAboutToBeDestroyed(toDestroy);
for (const auto &item : toDestroy) {
item->destroy();
}
}
for (const auto &history : historiesToCheck) {
history->requestChatListMessage();
}