Handle chat link clicks.

This commit is contained in:
John Preston
2024-03-26 19:13:26 +04:00
parent 3d54f8ec49
commit f240cbbda6
6 changed files with 96 additions and 2 deletions
+26
View File
@@ -14,6 +14,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "history/history_widget.h"
#include "history/history_item_components.h"
#include "main/main_session.h"
#include "data/data_changes.h"
#include "data/data_session.h"
#include "data/data_web_page.h"
#include "mainwidget.h"
@@ -128,4 +129,29 @@ void ClearPeerCloudDraft(
history->applyCloudDraft(topicRootId);
}
void SetChatLinkDraft(
not_null<PeerData*> peer,
const TextWithEntities &draft) {
const auto textWithTags = TextWithTags{
draft.text,
TextUtilities::ConvertEntitiesToTextTags(draft.entities)
};
const auto cursor = MessageCursor{
int(textWithTags.text.size()),
int(textWithTags.text.size()),
Ui::kQFixedMax
};
const auto history = peer->owner().history(peer->id);
const auto topicRootId = MsgId();
history->setLocalDraft(std::make_unique<Data::Draft>(
textWithTags,
FullReplyTo{ .topicRootId = topicRootId },
cursor,
Data::WebPageDraft()));
history->clearLocalEditDraft(topicRootId);
history->session().changes().entryUpdated(
history,
Data::EntryUpdate::Flag::LocalDraftSet);
}
} // namespace Data