Don't accept drafts older than last saved.

I hope it finally fixes #4922, partially fixes #10001.

The rest of #10001 like RAM usage / crashes are unrelated to drafts.
This commit is contained in:
John Preston
2021-03-12 15:18:33 +04:00
parent 74c21039b3
commit 5794679277
4 changed files with 86 additions and 52 deletions
+7 -6
View File
@@ -48,7 +48,11 @@ void ApplyPeerCloudDraft(
PeerId peerId,
const MTPDdraftMessage &draft) {
const auto history = session->data().history(peerId);
const auto textWithTags = TextWithTags {
const auto date = draft.vdate().v;
if (history->skipCloudDraftUpdate(date)) {
return;
}
const auto textWithTags = TextWithTags{
qs(draft.vmessage()),
TextUtilities::ConvertEntitiesToTextTags(
Api::EntitiesFromMTP(
@@ -56,9 +60,6 @@ void ApplyPeerCloudDraft(
draft.ventities().value_or_empty()))
};
const auto replyTo = draft.vreply_to_msg_id().value_or_empty();
if (history->skipCloudDraft(textWithTags.text, replyTo, draft.vdate().v)) {
return;
}
auto cloudDraft = std::make_unique<Draft>(
textWithTags,
replyTo,
@@ -66,7 +67,7 @@ void ApplyPeerCloudDraft(
(draft.is_no_webpage()
? Data::PreviewState::Cancelled
: Data::PreviewState::Allowed));
cloudDraft->date = draft.vdate().v;
cloudDraft->date = date;
history->setCloudDraft(std::move(cloudDraft));
history->applyCloudDraft();
@@ -77,7 +78,7 @@ void ClearPeerCloudDraft(
PeerId peerId,
TimeId date) {
const auto history = session->data().history(peerId);
if (history->skipCloudDraft(QString(), MsgId(0), date)) {
if (history->skipCloudDraftUpdate(date)) {
return;
}