Add additional prize info to giveaway details.

This commit is contained in:
John Preston 2023-12-08 11:36:30 +04:00
parent 8abc35ca86
commit d56724f290
4 changed files with 37 additions and 13 deletions

View file

@ -2216,6 +2216,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_prizes_end_text" = "This giveaway was sponsored by {admins}.";
"lng_prizes_admins#one" = "the admins of {channel}, who aquired **{count} Telegram Premium** subscription {duration} for its followers";
"lng_prizes_admins#other" = "the admins of {channel}, who aquired **{count} Telegram Premium** subscriptions {duration} for its followers.";
"lng_prizes_additional_added#one" = "{channel} also included **{count} {prize}** in the prize. Admins of the channel are responsible for delivering this prize.";
"lng_prizes_additional_added#other" = "{channel} also included **{count} {prize}** in the prizes. Admins of the channel are responsible for delivering these prizes.";
"lng_prizes_how_when_finish" = "On {date}, Telegram will automatically select {winners}.";
"lng_prizes_end_when_finish" = "On {date}, Telegram automatically selected {winners}.";
"lng_prizes_end_activated#one" = "**{count}** of the winners already used their gift link.";

View file

@ -752,7 +752,22 @@ void GiveawayInfoBox(
const auto first = !giveaway.channels.empty()
? giveaway.channels.front()->name()
: u"channel"_q;
auto text = (finished
auto text = TextWithEntities();
if (!info.giftCode.isEmpty()) {
text.append("\n\n");
text.append(Ui::Text::Bold(tr::lng_prizes_you_won(
tr::now,
lt_cup,
QString::fromUtf8("\xf0\x9f\x8f\x86"))));
text.append("\n\n");
} else if (info.state == State::Finished) {
text.append("\n\n");
text.append(Ui::Text::Bold(tr::lng_prizes_you_didnt(tr::now)));
text.append("\n\n");
}
text.append((finished
? tr::lng_prizes_end_text
: tr::lng_prizes_how_text)(
tr::now,
@ -766,7 +781,7 @@ void GiveawayInfoBox(
lt_duration,
TextWithEntities{ GiftDuration(giveaway.months) },
Ui::Text::RichLangValue),
Ui::Text::RichLangValue);
Ui::Text::RichLangValue));
const auto many = (giveaway.channels.size() > 1);
const auto count = info.winnersCount
? info.winnersCount
@ -793,6 +808,17 @@ void GiveawayInfoBox(
Ui::Text::Bold(
langDateTime(base::unixtime::parse(info.startDate))),
Ui::Text::RichLangValue);
if (!giveaway.additionalPrize.isEmpty()) {
text.append("\n\n").append(tr::lng_prizes_additional_added(
tr::now,
lt_count,
count,
lt_channel,
Ui::Text::Bold(first),
lt_prize,
TextWithEntities{ giveaway.additionalPrize },
Ui::Text::RichLangValue));
}
text.append("\n\n").append((finished
? tr::lng_prizes_end_when_finish
: tr::lng_prizes_how_when_finish)(
@ -810,17 +836,9 @@ void GiveawayInfoBox(
info.activatedCount,
Ui::Text::RichLangValue));
}
if (!info.giftCode.isEmpty()) {
text.append("\n\n");
text.append(tr::lng_prizes_you_won(
tr::now,
lt_cup,
QString::fromUtf8("\xf0\x9f\x8f\x86")));
} else if (info.state == State::Finished) {
text.append("\n\n");
text.append(tr::lng_prizes_you_didnt(tr::now));
} else if (info.state == State::Preparing) {
if (!info.giftCode.isEmpty()
|| info.state == State::Finished
|| info.state == State::Preparing) {
} else if (info.state != State::Refunded) {
if (info.adminChannelId) {
const auto channel = controller->session().data().channel(

View file

@ -383,6 +383,9 @@ Giveaway ComputeGiveawayData(
result.countries.push_back(qs(country));
}
}
if (const auto additional = data.vprize_description()) {
result.additionalPrize = qs(*additional);
}
return result;
}

View file

@ -93,6 +93,7 @@ struct Invoice {
struct Giveaway {
std::vector<not_null<ChannelData*>> channels;
std::vector<QString> countries;
QString additionalPrize;
TimeId untilDate = 0;
int quantity = 0;
int months = 0;