mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved API support of boosts list.
This commit is contained in:
parent
1852161fbf
commit
9df551a145
5 changed files with 45 additions and 11 deletions
|
@ -567,9 +567,30 @@ 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());
|
||||||
for (const auto &boost : data.vboosts().v) {
|
for (const auto &boost : data.vboosts().v) {
|
||||||
|
const auto &data = boost.data();
|
||||||
|
const auto path = data.vused_gift_slug()
|
||||||
|
? (u"giftcode/"_q + qs(data.vused_gift_slug()->v))
|
||||||
|
: QString();
|
||||||
|
auto giftCodeLink = !path.isEmpty()
|
||||||
|
? Data::GiftCodeLink{
|
||||||
|
_peer->session().createInternalLink(path),
|
||||||
|
_peer->session().createInternalLinkFull(path),
|
||||||
|
qs(data.vused_gift_slug()->v),
|
||||||
|
}
|
||||||
|
: Data::GiftCodeLink();
|
||||||
list.push_back({
|
list.push_back({
|
||||||
boost.data().vuser_id().value_or_empty(),
|
data.is_gift(),
|
||||||
QDateTime::fromSecsSinceEpoch(boost.data().vexpires().v),
|
data.is_giveaway(),
|
||||||
|
data.is_unclaimed(),
|
||||||
|
qs(data.vid()),
|
||||||
|
data.vuser_id().value_or_empty(),
|
||||||
|
data.vgiveaway_msg_id()
|
||||||
|
? FullMsgId{ _peer->id, data.vgiveaway_msg_id()->v }
|
||||||
|
: FullMsgId(),
|
||||||
|
QDateTime::fromSecsSinceEpoch(data.vdate().v),
|
||||||
|
data.vexpires().v,
|
||||||
|
std::move(giftCodeLink),
|
||||||
|
data.vmultiplier().value_or_empty(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
done(Data::BoostsListSlice{
|
done(Data::BoostsListSlice{
|
||||||
|
|
|
@ -13,6 +13,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "base/weak_ptr.h"
|
#include "base/weak_ptr.h"
|
||||||
#include "boxes/peers/prepare_short_info_box.h"
|
#include "boxes/peers/prepare_short_info_box.h"
|
||||||
|
#include "data/data_boosts.h"
|
||||||
#include "data/data_changes.h"
|
#include "data/data_changes.h"
|
||||||
#include "data/data_channel.h"
|
#include "data/data_channel.h"
|
||||||
#include "data/data_media_types.h" // Data::Giveaway
|
#include "data/data_media_types.h" // Data::Giveaway
|
||||||
|
@ -237,11 +238,7 @@ void GiftBox(
|
||||||
}, box->lifetime());
|
}, box->lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GiftCodeLink {
|
[[nodiscard]] Data::GiftCodeLink MakeGiftCodeLink(
|
||||||
QString text;
|
|
||||||
QString link;
|
|
||||||
};
|
|
||||||
[[nodiscard]] GiftCodeLink MakeGiftCodeLink(
|
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
const QString &slug) {
|
const QString &slug) {
|
||||||
const auto path = u"giftcode/"_q + slug;
|
const auto path = u"giftcode/"_q + slug;
|
||||||
|
|
|
@ -19,9 +19,24 @@ struct BoostsOverview final {
|
||||||
float64 premiumMemberPercentage = 0;
|
float64 premiumMemberPercentage = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GiftCodeLink final {
|
||||||
|
QString text;
|
||||||
|
QString link;
|
||||||
|
QString slug;
|
||||||
|
};
|
||||||
|
|
||||||
struct Boost final {
|
struct Boost final {
|
||||||
|
bool isGift = false;
|
||||||
|
bool isGiveaway = false;
|
||||||
|
bool isUnclaimed = false;
|
||||||
|
|
||||||
|
QString id;
|
||||||
UserId userId = UserId(0);
|
UserId userId = UserId(0);
|
||||||
QDateTime expirationDate;
|
FullMsgId giveawayMessage;
|
||||||
|
QDateTime date;
|
||||||
|
crl::time expiresAt = 0;
|
||||||
|
GiftCodeLink giftCodeLink;
|
||||||
|
int multiplier = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BoostsListSlice final {
|
struct BoostsListSlice final {
|
||||||
|
|
|
@ -100,8 +100,9 @@ void FillOverview(
|
||||||
const auto topLeftLabel = addPrimary(stats.level);
|
const auto topLeftLabel = addPrimary(stats.level);
|
||||||
const auto topRightLabel = addPrimary(stats.premiumMemberCount);
|
const auto topRightLabel = addPrimary(stats.premiumMemberCount);
|
||||||
const auto bottomLeftLabel = addPrimary(stats.boostCount);
|
const auto bottomLeftLabel = addPrimary(stats.boostCount);
|
||||||
const auto bottomRightLabel = addPrimary(
|
const auto bottomRightLabel = addPrimary(std::max(
|
||||||
stats.nextLevelBoostCount - stats.boostCount);
|
stats.nextLevelBoostCount - stats.boostCount,
|
||||||
|
0));
|
||||||
|
|
||||||
addSub(
|
addSub(
|
||||||
topLeftLabel,
|
topLeftLabel,
|
||||||
|
|
|
@ -397,7 +397,7 @@ void BoostsController::applySlice(const Data::BoostsListSlice &slice) {
|
||||||
row->setCustomStatus(tr::lng_boosts_list_status(
|
row->setCustomStatus(tr::lng_boosts_list_status(
|
||||||
tr::now,
|
tr::now,
|
||||||
lt_date,
|
lt_date,
|
||||||
QLocale().toString(item.expirationDate, formatter)));
|
QLocale().toString(item.date, formatter)));
|
||||||
delegate()->peerListAppendRow(std::move(row));
|
delegate()->peerListAppendRow(std::move(row));
|
||||||
}
|
}
|
||||||
delegate()->peerListRefreshRows();
|
delegate()->peerListRefreshRows();
|
||||||
|
|
Loading…
Add table
Reference in a new issue