2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Removed text commands from history item components.

This commit is contained in:
23rd
2021-12-26 19:29:25 +03:00
committed by John Preston
parent d6801517bb
commit b55ed7214a
20 changed files with 717 additions and 406 deletions

View File

@@ -47,30 +47,18 @@ constexpr auto kSystemAlertDuration = crl::time(1000);
constexpr auto kSystemAlertDuration = crl::time(0);
#endif // Q_OS_MAC
QString TextWithPermanentSpoiler(QString textWithCommands) {
const auto start = textcmdStartSpoiler();
const auto stop = textcmdStopSpoiler();
while (true) {
const auto startIndex = textWithCommands.indexOf(start);
if (startIndex == -1) {
break;
QString TextWithPermanentSpoiler(const TextWithEntities &textWithEntities) {
auto text = textWithEntities.text;
for (const auto &e : textWithEntities.entities) {
if (e.type() == EntityType::Spoiler) {
auto replacement = QString().fill(QChar(0x259A), e.length());
text = text.replace(
e.offset(),
e.length(),
std::move(replacement));
}
const auto stopIndex = textWithCommands.indexOf(stop);
if (stopIndex == -1) {
break;
}
if (stopIndex < startIndex) {
break;
}
const auto length = stopIndex - startIndex - start.size();
textWithCommands.remove(stopIndex, stop.size());
textWithCommands.remove(startIndex, start.size());
textWithCommands.replace(
startIndex,
length,
QString(QChar(0x259A)).repeated(length));
}
return textWithCommands;
return text;
}
} // namespace