Added utility to correctly cut text with commands.

This commit is contained in:
23rd 2021-12-25 17:31:31 +03:00 committed by John Preston
parent 8b74dc2dec
commit c40bcdc446
3 changed files with 11 additions and 3 deletions

View file

@ -1029,7 +1029,11 @@ QString HistoryItem::notificationText() const {
}(); }();
return (result.size() <= kNotificationTextLimit) return (result.size() <= kNotificationTextLimit)
? result ? result
: result.mid(0, kNotificationTextLimit) + qsl("..."); : TextUtilities::CutTextWithCommands(
result,
kNotificationTextLimit,
textcmdStartSpoiler(),
textcmdStopSpoiler());
} }
ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const { ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const {

View file

@ -711,7 +711,11 @@ HistoryService::PreparedText HistoryService::preparePinnedText() {
} }
} }
if (!limit && cutAt + 5 < size) { 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)); result.text = tr::lng_action_pinned_message(tr::now, lt_from, fromLinkText(), lt_text, textcmdLink(2, original));
} else { } else {

@ -1 +1 @@
Subproject commit 44853e933400a7f1536b9847fd0adc2b7d575bff Subproject commit 774da18a386e9f0eda71331db22bc8e9b24bf44e