2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Move message ownership to History.

This commit is contained in:
John Preston
2020-02-20 12:45:25 +04:00
parent 6357529901
commit c8d2ac9583
13 changed files with 138 additions and 130 deletions

View File

@@ -2424,7 +2424,8 @@ int ApiWrap::OnlineTillFromStatus(
void ApiWrap::clearHistory(not_null<PeerData*> peer, bool revoke) {
auto deleteTillId = MsgId(0);
if (const auto history = _session->data().historyLoaded(peer)) {
const auto history = _session->data().historyLoaded(peer);
if (history) {
while (history->lastMessageKnown()) {
const auto last = history->lastMessage();
if (!last) {
@@ -2446,7 +2447,6 @@ void ApiWrap::clearHistory(not_null<PeerData*> peer, bool revoke) {
return;
}
deleteTillId = history->lastMessage()->id;
history->clear(History::ClearType::ClearHistory);
}
if (const auto channel = peer->asChannel()) {
if (const auto migrated = peer->migrateFrom()) {
@@ -2461,6 +2461,9 @@ void ApiWrap::clearHistory(not_null<PeerData*> peer, bool revoke) {
} else {
deleteHistory(peer, true, revoke);
}
if (history) {
history->clear(History::ClearType::ClearHistory);
}
}
void ApiWrap::deleteConversation(not_null<PeerData*> peer, bool revoke) {