Cloud draft handling improved. Fixed Edit while already editing a msg.

This commit is contained in:
John Preston
2016-06-09 17:31:10 +03:00
parent 19cacd0efb
commit a428534345
14 changed files with 197 additions and 145 deletions
+16 -1
View File
@@ -23,6 +23,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "historywidget.h"
#include "mainwidget.h"
#include "localstorage.h"
namespace Data {
namespace {
@@ -35,7 +36,7 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
auto entities = draft.has_entities() ? entitiesFromMTP(draft.ventities.c_vector().v) : EntitiesInText();
TextWithTags textWithTags = { textApplyEntities(text, entities), textTagsFromEntities(entities) };
MsgId replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : 0;
auto cloudDraft = std_::make_unique<HistoryDraft>(textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage());
auto cloudDraft = std_::make_unique<Draft>(textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage());
cloudDraft->date = ::date(draft.vdate);
history->setCloudDraft(std_::move(cloudDraft));
@@ -48,4 +49,18 @@ void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
}
}
void clearPeerCloudDraft(PeerId peerId) {
auto history = App::history(peerId);
history->clearCloudDraft();
history->clearLocalDraft();
history->updateChatListSortPosition();
history->updateChatListEntry();
if (auto main = App::main()) {
main->applyCloudDraft(history);
}
}
} // namespace Data