void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) { const auto history = App::history(peerId); const auto textWithTags = TextWithTags { qs(draft.vmessage), ConvertEntitiesToTextTags( draft.has_entities() ? TextUtilities::EntitiesFromMTP(draft.ventities.v) : EntitiesInText()) }; 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 cloudDraft = std::make_unique<Draft>( textWithTags, replyTo, MessageCursor(QFIXED_MAX, QFIXED_MAX, QFIXED_MAX), draft.is_no_webpage()); cloudDraft->date = draft.vdate.v; history->setCloudDraft(std::move(cloudDraft)); history->createLocalDraftFromCloud(); if (Auth().supportMode()) { history->updateChatListEntry(); Auth().supportHelper().cloudDraftChanged(history); } else { history->updateChatListSortPosition(); } if (const auto main = App::main()) { main->applyCloudDraft(history); } }
void Entry::setChatListExistence(bool exists) { if (const auto main = App::main()) { if (exists && _sortKeyInChatList) { main->createDialog(_key); updateChatListEntry(); } else { main->removeDialog(_key); } } }
void Entry::cacheProxyPromoted(bool promoted) { if (_isProxyPromoted != promoted) { _isProxyPromoted = promoted; updateChatListSortPosition(); updateChatListEntry(); if (!_isProxyPromoted) { updateChatListExistence(); } } }
void Entry::cachePinnedIndex(int index) { if (_pinnedIndex != index) { const auto wasPinned = isPinnedDialog(); _pinnedIndex = index; updateChatListSortPosition(); updateChatListEntry(); if (wasPinned != isPinnedDialog()) { changedChatListPinHook(); } } }
void Entry::updateChatListSortPosition() { if (Auth().supportMode() && _sortKeyInChatList != 0 && Auth().settings().supportFixChatsOrder()) { updateChatListEntry(); return; } _sortKeyInChatList = useProxyPromotion() ? ProxyPromotedDialogPos() : isPinnedDialog() ? PinnedDialogPos(_pinnedIndex) : DialogPosFromDate(adjustChatListTimeId()); if (needUpdateInChatList()) { setChatListExistence(true); } }
void clearPeerCloudDraft(PeerId peerId, TimeId date) { const auto history = App::history(peerId); if (history->skipCloudDraft(QString(), MsgId(0), date)) { return; } history->clearCloudDraft(); history->clearLocalDraft(); if (Auth().supportMode()) { history->updateChatListEntry(); Auth().supportHelper().cloudDraftChanged(history); } else { history->updateChatListSortPosition(); } if (auto main = App::main()) { main->applyCloudDraft(history); } }