Async dashboard (#3916)

* Dashboard: Load Lightning balance async, display default currency

* Simplify approach, improve views and scripts

* Async tiles


Async tiles

* Add period for app sales

* Fix missing keypad view sales

* Fix after rebase

* Fix awaited call

* Fix build

Co-authored-by: Nicolas Dorier <nicolas.dorier@gmail.com>
This commit is contained in:
d11n
2022-07-06 05:40:16 +02:00
committed by GitHub
parent 19aaff2345
commit 657423207b
25 changed files with 459 additions and 265 deletions

View File

@@ -21,32 +21,27 @@ namespace BTCPayServer.Components.StoreRecentTransactions;
public class StoreRecentTransactions : ViewComponent
{
private string CryptoCode;
private readonly StoreRepository _storeRepo;
private readonly ApplicationDbContextFactory _dbContextFactory;
private readonly BTCPayWalletProvider _walletProvider;
public BTCPayNetworkProvider NetworkProvider { get; }
public StoreRecentTransactions(
StoreRepository storeRepo,
BTCPayNetworkProvider networkProvider,
NBXplorerConnectionFactory connectionFactory,
BTCPayWalletProvider walletProvider,
ApplicationDbContextFactory dbContextFactory)
BTCPayWalletProvider walletProvider)
{
_storeRepo = storeRepo;
NetworkProvider = networkProvider;
_walletProvider = walletProvider;
_dbContextFactory = dbContextFactory;
CryptoCode = networkProvider.DefaultNetwork.CryptoCode;
}
public async Task<IViewComponentResult> InvokeAsync(StoreData store)
public async Task<IViewComponentResult> InvokeAsync(StoreRecentTransactionsViewModel vm)
{
var walletId = new WalletId(store.Id, CryptoCode);
var derivationSettings = store.GetDerivationSchemeSettings(NetworkProvider, walletId.CryptoCode);
if (vm.Store == null) throw new ArgumentNullException(nameof(vm.Store));
if (vm.CryptoCode == null) throw new ArgumentNullException(nameof(vm.CryptoCode));
vm.WalletId = new WalletId(vm.Store.Id, vm.CryptoCode);
if (vm.InitialRendering) return View(vm);
var derivationSettings = vm.Store.GetDerivationSchemeSettings(NetworkProvider, vm.CryptoCode);
var transactions = new List<StoreRecentTransactionViewModel>();
if (derivationSettings?.AccountDerivation is not null)
{
@@ -66,13 +61,8 @@ public class StoreRecentTransactions : ViewComponent
.ToList();
}
var vm = new StoreRecentTransactionsViewModel
{
Store = store,
WalletId = walletId,
Transactions = transactions
};
vm.Transactions = transactions;
return View(vm);
}
}