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:
@@ -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
|
||||
|
Reference in New Issue
Block a user