mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved api support to credit history entries.
This commit is contained in:
parent
d0a030ab58
commit
7d115b3fab
2 changed files with 22 additions and 5 deletions
|
@ -30,6 +30,12 @@ constexpr auto kTransactionsLimit = 100;
|
||||||
const auto photo = tl.data().vphoto()
|
const auto photo = tl.data().vphoto()
|
||||||
? peer->owner().photoFromWeb(*tl.data().vphoto(), ImageLocation())
|
? peer->owner().photoFromWeb(*tl.data().vphoto(), ImageLocation())
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
const auto barePeerId = tl.data().vpeer().match([](
|
||||||
|
const HistoryPeerTL &p) {
|
||||||
|
return peerFromMTP(p.vpeer());
|
||||||
|
}, [](const auto &) {
|
||||||
|
return PeerId(0);
|
||||||
|
}).value;
|
||||||
return Data::CreditsHistoryEntry{
|
return Data::CreditsHistoryEntry{
|
||||||
.id = qs(tl.data().vid()),
|
.id = qs(tl.data().vid()),
|
||||||
.title = qs(tl.data().vtitle().value_or_empty()),
|
.title = qs(tl.data().vtitle().value_or_empty()),
|
||||||
|
@ -37,11 +43,7 @@ constexpr auto kTransactionsLimit = 100;
|
||||||
.date = base::unixtime::parse(tl.data().vdate().v),
|
.date = base::unixtime::parse(tl.data().vdate().v),
|
||||||
.photoId = photo ? photo->id : 0,
|
.photoId = photo ? photo->id : 0,
|
||||||
.credits = tl.data().vstars().v,
|
.credits = tl.data().vstars().v,
|
||||||
.bareId = tl.data().vpeer().match([](const HistoryPeerTL &p) {
|
.bareId = barePeerId,
|
||||||
return peerFromMTP(p.vpeer());
|
|
||||||
}, [](const auto &) {
|
|
||||||
return PeerId(0);
|
|
||||||
}).value,
|
|
||||||
.peerType = tl.data().vpeer().match([](const HistoryPeerTL &) {
|
.peerType = tl.data().vpeer().match([](const HistoryPeerTL &) {
|
||||||
return Data::CreditsHistoryEntry::PeerType::Peer;
|
return Data::CreditsHistoryEntry::PeerType::Peer;
|
||||||
}, [](const MTPDstarsTransactionPeerPlayMarket &) {
|
}, [](const MTPDstarsTransactionPeerPlayMarket &) {
|
||||||
|
@ -56,6 +58,15 @@ constexpr auto kTransactionsLimit = 100;
|
||||||
return Data::CreditsHistoryEntry::PeerType::PremiumBot;
|
return Data::CreditsHistoryEntry::PeerType::PremiumBot;
|
||||||
}),
|
}),
|
||||||
.refunded = tl.data().is_refund(),
|
.refunded = tl.data().is_refund(),
|
||||||
|
.pending = tl.data().is_pending(),
|
||||||
|
.failed = tl.data().is_failed(),
|
||||||
|
.finishDate = tl.data().vtransaction_date()
|
||||||
|
? base::unixtime::parse(tl.data().vtransaction_date()->v)
|
||||||
|
: QDateTime(),
|
||||||
|
.finishUrl = qs(tl.data().vtransaction_url().value_or_empty()),
|
||||||
|
.in = (!barePeerId || tl.data().is_refund())
|
||||||
|
&& !tl.data().is_pending()
|
||||||
|
&& !tl.data().is_failed(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,12 @@ struct CreditsHistoryEntry final {
|
||||||
uint64 bareId = 0;
|
uint64 bareId = 0;
|
||||||
PeerType peerType;
|
PeerType peerType;
|
||||||
bool refunded = false;
|
bool refunded = false;
|
||||||
|
bool pending = false;
|
||||||
|
bool failed = false;
|
||||||
|
QDateTime finishDate;
|
||||||
|
QString finishUrl;
|
||||||
|
bool in = false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CreditsStatusSlice final {
|
struct CreditsStatusSlice final {
|
||||||
|
|
Loading…
Add table
Reference in a new issue