2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-05 17:06:03 +00:00

Simplify paid message button labeling.

This commit is contained in:
John Preston
2025-02-28 14:35:24 +04:00
parent 97b021efaf
commit 8ea7bd4913
7 changed files with 48 additions and 41 deletions

View File

@@ -1280,3 +1280,26 @@ void SelectTextInFieldWithMargins(
textCursor.setPosition(selection.to, QTextCursor::KeepAnchor);
field->setTextCursor(textCursor);
}
TextWithEntities PaidSendButtonText(tr::now_t, int stars) {
return Ui::Text::IconEmoji(&st::boxStarIconEmoji).append(
Lang::FormatCountToShort(stars).string);
}
rpl::producer<TextWithEntities> PaidSendButtonText(
rpl::producer<int> stars,
rpl::producer<QString> fallback) {
if (fallback) {
return rpl::combine(
std::move(fallback),
std::move(stars)
) | rpl::map([=](QString zero, int count) {
return count
? PaidSendButtonText(tr::now, count)
: TextWithEntities{ zero };
});
}
return std::move(stars) | rpl::map([=](int count) {
return PaidSendButtonText(tr::now, count);
});
}