Esempio n. 1
0
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::setChatsListTimeId(TimeId date) {
	if (_lastMessageTimeId && _lastMessageTimeId >= date) {
		if (!inChatList(Dialogs::Mode::All)) {
			return;
		}
	}
	_lastMessageTimeId = date;
	updateChatListSortPosition();
}
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();
		}
	}
}
Esempio n. 5
0
void clearPeerCloudDraft(PeerId peerId) {
	auto history = App::history(peerId);

	history->clearCloudDraft();
	history->clearLocalDraft();

	history->updateChatListSortPosition();

	if (auto main = App::main()) {
		main->applyCloudDraft(history);
	}
}
Esempio n. 6
0
void applyPeerCloudDraft(PeerId peerId, const MTPDdraftMessage &draft) {
	auto history = App::history(peerId);
	auto text = TextWithEntities { qs(draft.vmessage), draft.has_entities() ? TextUtilities::EntitiesFromMTP(draft.ventities.v) : EntitiesInText() };
	auto textWithTags = TextWithTags { TextUtilities::ApplyEntities(text), ConvertEntitiesToTextTags(text.entities) };
	auto replyTo = draft.has_reply_to_msg_id() ? draft.vreply_to_msg_id.v : MsgId(0);
	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();
	history->updateChatListSortPosition();

	if (auto main = App::main()) {
		main->applyCloudDraft(history);
	}
}
Esempio n. 7
0
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);
	}
}