diff --git a/Telegram/SourceFiles/data/components/credits.cpp b/Telegram/SourceFiles/data/components/credits.cpp index 4c2379a95..e213fcf9a 100644 --- a/Telegram/SourceFiles/data/components/credits.cpp +++ b/Telegram/SourceFiles/data/components/credits.cpp @@ -74,6 +74,11 @@ uint64 Credits::balance(PeerId peerId) const { return (it != _cachedPeerBalances.end()) ? it->second : 0; } +uint64 Credits::balanceCurrency(PeerId peerId) const { + const auto it = _cachedPeerCurrencyBalances.find(peerId); + return (it != _cachedPeerCurrencyBalances.end()) ? it->second : 0; +} + rpl::producer Credits::balanceValue() const { return _nonLockedBalance.value(); } @@ -128,4 +133,8 @@ void Credits::apply(PeerId peerId, uint64 balance) { _cachedPeerBalances[peerId] = balance; } +void Credits::applyCurrency(PeerId peerId, uint64 balance) { + _cachedPeerCurrencyBalances[peerId] = balance; +} + } // namespace Data diff --git a/Telegram/SourceFiles/data/components/credits.h b/Telegram/SourceFiles/data/components/credits.h index 62fefcc3c..da953b29b 100644 --- a/Telegram/SourceFiles/data/components/credits.h +++ b/Telegram/SourceFiles/data/components/credits.h @@ -35,6 +35,9 @@ public: [[nodiscard]] rpl::producer rateValue( not_null ownedBotOrChannel); + void applyCurrency(PeerId peerId, uint64 balance); + [[nodiscard]] uint64 balanceCurrency(PeerId peerId) const; + void lock(int count); void unlock(int count); void withdrawLocked(int count); @@ -50,6 +53,7 @@ private: std::unique_ptr _loader; base::flat_map _cachedPeerBalances; + base::flat_map _cachedPeerCurrencyBalances; uint64 _balance = 0; uint64 _locked = 0;