2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 08:55:59 +00:00

Message edit: check changes correctly.

This commit is contained in:
John Preston
2023-08-21 11:00:38 +02:00
parent e8e74e7ac7
commit 2f9ae75a65
5 changed files with 75 additions and 14 deletions

View File

@@ -279,6 +279,19 @@ TextWithTags PrepareEditText(not_null<HistoryItem*> item) {
};
}
bool EditTextChanged(
not_null<HistoryItem*> item,
const TextWithTags &updated) {
const auto original = PrepareEditText(item);
// Tags can be different for the same entities, because for
// animated emoji each tag contains a different random number.
// So we compare entities instead of tags.
return (original.text != updated.text)
|| (TextUtilities::ConvertTextTagsToEntities(original.tags)
!= TextUtilities::ConvertTextTagsToEntities(updated.tags));
}
Fn<bool(
Ui::InputField::EditLinkSelection selection,
QString text,
@@ -595,6 +608,10 @@ void MessageLinksParser::parseNow() {
parse();
}
void MessageLinksParser::setDisabled(bool disabled) {
_disabled = disabled;
}
bool MessageLinksParser::eventFilter(QObject *object, QEvent *event) {
if (object == _field) {
if (event->type() == QEvent::KeyPress) {
@@ -625,7 +642,7 @@ void MessageLinksParser::parse() {
const auto &text = textWithTags.text;
const auto &tags = textWithTags.tags;
const auto &markdownTags = _field->getMarkdownTags();
if (text.isEmpty()) {
if (_disabled || text.isEmpty()) {
_list = QStringList();
return;
}