add balance also to new User, for replacing old user model in CheckTransactionPage

This commit is contained in:
Dario 2020-06-29 14:20:53 +02:00
parent ed0aa38813
commit 07ff9be91e
3 changed files with 12 additions and 1 deletions

View File

@ -37,6 +37,10 @@ Poco::JSON::Object* JsonTransaction::handle(Poco::Dynamic::Var params)
if (u) {
u->setBalance(balance);
}
auto nu = session->getNewUser();
if (!nu.isNull()) {
nu->setBalance(balance);
}
}
}

View File

@ -16,7 +16,7 @@
namespace controller {
User::User(model::table::User* dbModel)
: mPassword(nullptr), mGradidoKeyPair(nullptr), mCanDecryptPrivateKey(false)
: mPassword(nullptr), mGradidoKeyPair(nullptr), mCanDecryptPrivateKey(false), mGradidoCurrentBalance(0)
{
mDBModel = dbModel;
}

View File

@ -109,6 +109,9 @@ namespace controller {
return mGradidoKeyPair;
}
inline void setBalance(int gradidoBalance) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mGradidoCurrentBalance = gradidoBalance; }
inline int getBalance() { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mGradidoCurrentBalance; }
protected:
User(model::table::User* dbModel);
@ -120,6 +123,10 @@ namespace controller {
bool mCanDecryptPrivateKey;
//! get this from community-server, later maybe from gradido-node
//! use it for showing balance in menu in check transaction
int mGradidoCurrentBalance;
mutable std::shared_mutex mSharedMutex;
};
}