Cloud stored message drafts support added.

This commit is contained in:
John Preston
2016-06-03 21:24:27 +03:00
parent 307e529ccf
commit cd2615d8d0
16 changed files with 431 additions and 151 deletions
+18
View File
@@ -21,13 +21,31 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
#include "stdafx.h"
#include "data/drafts.h"
#include "historywidget.h"
#include "mainwidget.h"
namespace Data {
namespace {
} // namespace
void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
auto history = App::history(peerId);
auto text = qs(draft.vmessage);
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());
cloudDraft->date = ::date(draft.vdate);
history->setCloudDraft(std_::move(cloudDraft));
history->createLocalDraftFromCloud();
history->updateChatListSortPosition();
history->updateChatListEntry();
if (auto main = App::main()) {
main->applyCloudDraft(history);
}
}
} // namespace Data