mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 02:01:40 -05:00
Fix clearing history with local messages.
This commit is contained in:
parent
e53f4a5450
commit
a27a80351a
1 changed files with 20 additions and 2 deletions
|
@ -2439,9 +2439,27 @@ int ApiWrap::OnlineTillFromStatus(
|
||||||
void ApiWrap::clearHistory(not_null<PeerData*> peer, bool revoke) {
|
void ApiWrap::clearHistory(not_null<PeerData*> peer, bool revoke) {
|
||||||
auto deleteTillId = MsgId(0);
|
auto deleteTillId = MsgId(0);
|
||||||
if (const auto history = _session->data().historyLoaded(peer)) {
|
if (const auto history = _session->data().historyLoaded(peer)) {
|
||||||
if (const auto last = history->lastMessage()) {
|
while (history->lastMessageKnown()) {
|
||||||
deleteTillId = last->id;
|
const auto last = history->lastMessage();
|
||||||
|
if (!last) {
|
||||||
|
// History is empty.
|
||||||
|
return;
|
||||||
|
} else if (!IsServerMsgId(last->id)) {
|
||||||
|
// Destroy client-side message locally.
|
||||||
|
last->destroy();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!history->lastMessageKnown()) {
|
||||||
|
requestDialogEntry(history, [=] {
|
||||||
|
Expects(history->lastMessageKnown());
|
||||||
|
|
||||||
|
clearHistory(peer, revoke);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
deleteTillId = history->lastMessage()->id;
|
||||||
history->clear(History::ClearType::ClearHistory);
|
history->clear(History::ClearType::ClearHistory);
|
||||||
}
|
}
|
||||||
if (const auto channel = peer->asChannel()) {
|
if (const auto channel = peer->asChannel()) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue