Skip to content

Commit

Permalink
f update tdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Sep 25, 2024
1 parent eb1a5bc commit fc8b404
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,14 @@ For license and copyright information please follow this link:
#include <QtSvg/QSvgRenderer>
#include <QtWidgets/QApplication>

#include "tdb/tdb_account.h"
#include "tdb/tdb_tl_scheme.h"

namespace Info::ChannelEarn {
namespace {

using namespace Tdb;

using EarnInt = Data::EarnInt;

[[nodiscard]] bool WithdrawalEnabled(not_null<Main::Session*> session) {
Expand Down Expand Up @@ -299,6 +304,41 @@ void InnerWidget::load() {
state->apiLifetime.destroy();
state->apiCreditsLifetime.destroy();

const auto peerId = _peer->id;
_peer->session().tdb().updates(
) | rpl::start_with_next([=](const TLupdate &update) {
update.match([&](const TLDupdateStarRevenueStatus &data) {
if (peerId != peerFromSender(data.vowner_id())) {
return;
}
const auto &status = data.vstatus().data();
auto &e = _state.creditsEarn;
e.currentBalance = status.vcurrent_count().v;
e.availableBalance = status.vavailable_count().v;
e.overallRevenue = status.vtotal_count().v;
e.isWithdrawalEnabled = status.vwithdrawal_enabled().v;
e.nextWithdrawalAt = (status.vwithdrawal_enabled().v
? QDateTime::currentDateTime().addSecs(
status.vnext_withdrawal_in().v)
: QDateTime()),
state->apiCreditsHistory.request({}, [=](
const Data::CreditsStatusSlice &data) {
_state.creditsStatusSlice = data;
_stateUpdated.fire({});
});
}, [&](const TLDupdateChatRevenueAmount &data) {
if (peerId != peerFromTdbChat(data.vchat_id())) {
return;
}
const auto &amount = data.vrevenue_amount().data();
auto &e = _state.currencyEarn;
e.currentBalance = amount.vbalance_amount().v;
e.availableBalance = amount.vavailable_amount().v;
e.overallRevenue = amount.vtotal_amount().v;
_stateUpdated.fire({});
}, [](const auto &) {});
}, lifetime());
#if 0 // mtp
_peer->session().account().mtpUpdates(
) | rpl::start_with_next([=, peerId = _peer->id](
const MTPUpdates &updates) {
Expand Down Expand Up @@ -350,6 +390,7 @@ void InnerWidget::load() {
}
});
}, lifetime());
#endif
};

_showFinished.events(
Expand All @@ -360,10 +401,12 @@ void InnerWidget::load() {
state->apiCreditsHistory.request({}, [=](
const Data::CreditsStatusSlice &data) {
_state.creditsStatusSlice = data;
#if 0 // mtp
::Api::PremiumPeerBot(
&_peer->session()
) | rpl::start_with_next([=](not_null<PeerData*> bot) {
_state.premiumBotId = bot->id;
#endif
state->apiCredits.request(
) | rpl::start_with_error_done([=](const QString &error) {
if (canViewCredits) {
Expand All @@ -376,8 +419,10 @@ void InnerWidget::load() {
_state.creditsEarn = state->apiCredits.data();
finish();
}, state->apiCreditsLifetime);
#if 0 // mtp
state->apiPremiumBotLifetime.destroy();
}, state->apiPremiumBotLifetime);
#endif
});
}, state->apiLifetime);
}, lifetime());
Expand Down

0 comments on commit fc8b404

Please sign in to comment.