Ignore only empty drafts while sending with clear_draft (#5424)

This commit is contained in:
udf 2018-12-26 08:52:48 +02:00 committed by John Preston
parent 71cf4a4885
commit 0b87db8b45
4 changed files with 10 additions and 7 deletions

View file

@ -53,10 +53,10 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
? TextUtilities::EntitiesFromMTP(draft.ventities.v)
: EntitiesInText())
};
if (history->skipCloudDraft(textWithTags.text, draft.vdate.v)) {
auto replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : MsgId(0);
if (history->skipCloudDraft(textWithTags.text, replyTo, draft.vdate.v)) {
return;
}
auto replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : MsgId(0);
auto cloudDraft = std::make_unique<Draft>(
textWithTags,
replyTo,
@ -80,7 +80,7 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
void clearPeerCloudDraft(PeerId peerId, TimeId date) {
const auto history = App::history(peerId);
if (history->skipCloudDraft(QString(), date)) {
if (history->skipCloudDraft(QString(), MsgId(0), date)) {
return;
}

View file

@ -512,8 +512,11 @@ Data::Draft *History::createCloudDraft(const Data::Draft *fromDraft) {
return cloudDraft();
}
bool History::skipCloudDraft(const QString &text, TimeId date) const {
if (date > 0 && date <= _lastSentDraftTime + kSkipCloudDraftsFor) {
bool History::skipCloudDraft(const QString &text, MsgId replyTo, TimeId date) const {
if (Data::draftStringIsEmpty(text)
&& !replyTo
&& date > 0
&& date <= _lastSentDraftTime + kSkipCloudDraftsFor) {
return true;
} else if (_lastSentDraftText && *_lastSentDraftText == text) {
return true;

View file

@ -326,7 +326,7 @@ public:
void createLocalDraftFromCloud();
void setCloudDraft(std::unique_ptr<Data::Draft> &&draft);
Data::Draft *createCloudDraft(const Data::Draft *fromDraft);
bool skipCloudDraft(const QString &text, TimeId date) const;
bool skipCloudDraft(const QString &text, MsgId replyTo, TimeId date) const;
void setSentDraftText(const QString &text);
void clearSentDraftText(const QString &text);
void setEditDraft(std::unique_ptr<Data::Draft> &&draft);

@ -1 +1 @@
Subproject commit 78e584c443b93ce2794bee75c7448d1b00f1edc9
Subproject commit fb0a2b0c9b59b3b19f9bc3c8a6aaf126f96d688f