From c40bcdc446a2a9d61a538473856eca2b2cc735f8 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Sat, 25 Dec 2021 17:31:31 +0300 Subject: [PATCH] Added utility to correctly cut text with commands. --- Telegram/SourceFiles/history/history_item.cpp | 6 +++++- Telegram/SourceFiles/history/history_service.cpp | 6 +++++- Telegram/lib_ui | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 367ae97f8c..629fec6842 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1029,7 +1029,11 @@ QString HistoryItem::notificationText() const { }(); return (result.size() <= kNotificationTextLimit) ? result - : result.mid(0, kNotificationTextLimit) + qsl("..."); + : TextUtilities::CutTextWithCommands( + result, + kNotificationTextLimit, + textcmdStartSpoiler(), + textcmdStopSpoiler()); } ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const { diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index d097473c4f..9c0361e6c3 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -711,7 +711,11 @@ HistoryService::PreparedText HistoryService::preparePinnedText() { } } if (!limit && cutAt + 5 < size) { - original = original.mid(0, cutAt) + qstr("..."); + original = TextUtilities::CutTextWithCommands( + std::move(original), + cutAt, + textcmdStartSpoiler(), + textcmdStopSpoiler()); } result.text = tr::lng_action_pinned_message(tr::now, lt_from, fromLinkText(), lt_text, textcmdLink(2, original)); } else { diff --git a/Telegram/lib_ui b/Telegram/lib_ui index 44853e9334..774da18a38 160000 --- a/Telegram/lib_ui +++ b/Telegram/lib_ui @@ -1 +1 @@ -Subproject commit 44853e933400a7f1536b9847fd0adc2b7d575bff +Subproject commit 774da18a386e9f0eda71331db22bc8e9b24bf44e