Fixed expiration date of boosts in boosts list.
This commit is contained in:
parent
282c076931
commit
33cf9a0702
4 changed files with 10 additions and 14 deletions
|
@ -587,6 +587,7 @@ void Boosts::requestBoosts(
|
||||||
|
|
||||||
auto list = std::vector<Data::Boost>();
|
auto list = std::vector<Data::Boost>();
|
||||||
list.reserve(data.vboosts().v.size());
|
list.reserve(data.vboosts().v.size());
|
||||||
|
constexpr auto kMonthsDivider = int(30 * 86400);
|
||||||
for (const auto &boost : data.vboosts().v) {
|
for (const auto &boost : data.vboosts().v) {
|
||||||
const auto &data = boost.data();
|
const auto &data = boost.data();
|
||||||
const auto path = data.vused_gift_slug()
|
const auto path = data.vused_gift_slug()
|
||||||
|
@ -609,7 +610,8 @@ void Boosts::requestBoosts(
|
||||||
? FullMsgId{ _peer->id, data.vgiveaway_msg_id()->v }
|
? FullMsgId{ _peer->id, data.vgiveaway_msg_id()->v }
|
||||||
: FullMsgId(),
|
: FullMsgId(),
|
||||||
QDateTime::fromSecsSinceEpoch(data.vdate().v),
|
QDateTime::fromSecsSinceEpoch(data.vdate().v),
|
||||||
data.vexpires().v,
|
QDateTime::fromSecsSinceEpoch(data.vexpires().v),
|
||||||
|
(data.vexpires().v - data.vdate().v) / kMonthsDivider,
|
||||||
std::move(giftCodeLink),
|
std::move(giftCodeLink),
|
||||||
data.vmultiplier().value_or_empty(),
|
data.vmultiplier().value_or_empty(),
|
||||||
});
|
});
|
||||||
|
|
|
@ -34,7 +34,8 @@ struct Boost final {
|
||||||
UserId userId = UserId(0);
|
UserId userId = UserId(0);
|
||||||
FullMsgId giveawayMessage;
|
FullMsgId giveawayMessage;
|
||||||
QDateTime date;
|
QDateTime date;
|
||||||
crl::time expiresAt = 0;
|
QDateTime expiresAt;
|
||||||
|
int expiresAfterMonths = 0;
|
||||||
GiftCodeLink giftCodeLink;
|
GiftCodeLink giftCodeLink;
|
||||||
int multiplier = 0;
|
int multiplier = 0;
|
||||||
};
|
};
|
||||||
|
|
|
@ -365,15 +365,11 @@ void InnerWidget::fill() {
|
||||||
} else if (boost.userId) {
|
} else if (boost.userId) {
|
||||||
const auto user = _peer->owner().user(boost.userId);
|
const auto user = _peer->owner().user(boost.userId);
|
||||||
if (boost.isGift || boost.isGiveaway) {
|
if (boost.isGift || boost.isGiveaway) {
|
||||||
constexpr auto kMonthsDivider = int(30 * 86400);
|
|
||||||
const auto date = TimeId(boost.date.toSecsSinceEpoch());
|
|
||||||
const auto months = (boost.expiresAt - date)
|
|
||||||
/ kMonthsDivider;
|
|
||||||
const auto d = Api::GiftCode{
|
const auto d = Api::GiftCode{
|
||||||
.from = _peer->id,
|
.from = _peer->id,
|
||||||
.to = user->id,
|
.to = user->id,
|
||||||
.date = date,
|
.date = TimeId(boost.date.toSecsSinceEpoch()),
|
||||||
.months = int(months),
|
.months = boost.expiresAfterMonths,
|
||||||
};
|
};
|
||||||
_show->showBox(Box(GiftCodePendingBox, _controller, d));
|
_show->showBox(Box(GiftCodePendingBox, _controller, d));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -391,19 +391,16 @@ BoostRow::BoostRow(const Data::Boost &boost)
|
||||||
|
|
||||||
void BoostRow::init() {
|
void BoostRow::init() {
|
||||||
invalidateBadges();
|
invalidateBadges();
|
||||||
constexpr auto kMonthsDivider = int(30 * 86400);
|
|
||||||
const auto months = (_boost.expiresAt - _boost.date.toSecsSinceEpoch())
|
|
||||||
/ kMonthsDivider;
|
|
||||||
auto status = !PeerListRow::special()
|
auto status = !PeerListRow::special()
|
||||||
? tr::lng_boosts_list_status(
|
? tr::lng_boosts_list_status(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_date,
|
lt_date,
|
||||||
langDateTime(_boost.date))
|
langDayOfMonth(_boost.expiresAt.date()))
|
||||||
: tr::lng_months_tiny(tr::now, lt_count, months)
|
: tr::lng_months_tiny(tr::now, lt_count, _boost.expiresAfterMonths)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ QChar(0x2022)
|
+ QChar(0x2022)
|
||||||
+ ' '
|
+ ' '
|
||||||
+ langDateTime(_boost.date);
|
+ langDayOfMonth(_boost.date.date());
|
||||||
PeerListRow::setCustomStatus(std::move(status));
|
PeerListRow::setCustomStatus(std::move(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue