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

Display date of birth in user profiles.

This commit is contained in:
John Preston
2024-03-22 19:12:11 +04:00
parent c82d7bd909
commit 08ee25deb2
10 changed files with 166 additions and 22 deletions

View File

@@ -635,5 +635,48 @@ rpl::producer<DocumentId> EmojiStatusIdValue(not_null<PeerData*> peer) {
) | rpl::map([=] { return peer->emojiStatusId(); });
}
rpl::producer<QString> BirthdayLabelText(
rpl::producer<Data::Birthday> birthday) {
return std::move(birthday) | rpl::map([](Data::Birthday value) {
return rpl::conditional(
Data::IsBirthdayTodayValue(value),
tr::lng_info_birthday_today_label(),
tr::lng_info_birthday_label());
}) | rpl::flatten_latest();
}
rpl::producer<QString> BirthdayValueText(
rpl::producer<Data::Birthday> birthday) {
return std::move(
birthday
) | rpl::map([](Data::Birthday value) -> rpl::producer<QString> {
if (!value) {
return rpl::single(QString());
}
return Data::IsBirthdayTodayValue(
value
) | rpl::map([=](bool today) {
auto text = Data::BirthdayText(value);
if (const auto age = Data::BirthdayAge(value)) {
text = tr::lng_info_birthday_years(
tr::now,
lt_count,
age,
lt_date,
text);
}
if (today) {
text = tr::lng_info_birthday_today(
tr::now,
lt_emoji,
Data::BirthdayCake(),
lt_date,
text);
}
return text;
});
}) | rpl::flatten_latest();
}
} // namespace Profile
} // namespace Info