From 6d419f166da698e6bd9d10a8a2fc52f20ca05ae1 Mon Sep 17 00:00:00 2001 From: Michiel Post Date: Fri, 29 Mar 2024 19:55:28 +0100 Subject: [PATCH] Loading fixes --- src/aoWebWallet/Pages/WalletDetail.razor | 7 ++---- src/aoWebWallet/Pages/WalletDetail.razor.cs | 3 ++- src/aoWebWallet/ViewModels/MainViewModel.cs | 26 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/aoWebWallet/Pages/WalletDetail.razor b/src/aoWebWallet/Pages/WalletDetail.razor index 4707843..4b7cb20 100644 --- a/src/aoWebWallet/Pages/WalletDetail.razor +++ b/src/aoWebWallet/Pages/WalletDetail.razor @@ -174,10 +174,7 @@ - @{ - var processes = BindingContext.ProcessesDataList?.Data?.Where(x => x.Data?.Address == BindingContext.SelectedAddress).FirstOrDefault(); - } - @if (processes?.Data?.Processes.Any() ?? false) + @if (BindingContext.SelectedProcessData?.Data?.Processes.Any() ?? false) { @@ -187,7 +184,7 @@ - @foreach (var process in processes.Data.Processes) + @foreach (var process in BindingContext.SelectedProcessData.Data.Processes) { var linkUrl = $"/wallet/{process.Id}"; diff --git a/src/aoWebWallet/Pages/WalletDetail.razor.cs b/src/aoWebWallet/Pages/WalletDetail.razor.cs index 4fba7ed..9ddfe91 100644 --- a/src/aoWebWallet/Pages/WalletDetail.razor.cs +++ b/src/aoWebWallet/Pages/WalletDetail.razor.cs @@ -13,6 +13,7 @@ protected override void OnInitialized() WatchDataLoaderVM(BindingContext.WalletList); WatchDataLoaderVM(BindingContext.BalanceDataList); WatchDataLoaderVM(BindingContext.TokenTransferList); + WatchDataLoaderVM(BindingContext.SelectedProcessData); base.OnInitialized(); } @@ -34,7 +35,7 @@ protected override void OnParametersSet() protected override async Task LoadDataAsync() { - await BindingContext.LoadTokenList(); + BindingContext.LoadTokenList(); //if (!string.IsNullOrEmpty(Address)) //{ diff --git a/src/aoWebWallet/ViewModels/MainViewModel.cs b/src/aoWebWallet/ViewModels/MainViewModel.cs index 725f780..bd4ada6 100644 --- a/src/aoWebWallet/ViewModels/MainViewModel.cs +++ b/src/aoWebWallet/ViewModels/MainViewModel.cs @@ -1,4 +1,5 @@ using aoWebWallet.Models; +using aoWebWallet.Pages; using aoWebWallet.Services; using ArweaveAO; using ArweaveAO.Models.Token; @@ -75,6 +76,7 @@ public partial class MainViewModel : ObservableRecipient public DataLoaderViewModel> TokenTransferList { get; set; } = new(); public DataLoaderViewModel SelectedTransaction { get; set; } = new(); public DataLoaderViewModel>> ProcessesDataList { get; set; } = new(); + public DataLoaderViewModel SelectedProcessData { get; set; } = new(); //TODO: @@ -242,6 +244,29 @@ public Task LoadProcessesDataList() => ProcessesDataList.DataLoader.LoadAsync(as }); + public async Task LoadSelectedWalletProcessData() + { + if (string.IsNullOrEmpty(SelectedAddress)) + return; + + SelectedProcessData.Data = null; + + var address = SelectedAddress; + + SelectedProcessData.Data = new WalletProcessDataViewModel { Address = address }; + + SelectedProcessData.DataLoader.LoadAsync(() => + { + return memoryDataCache!.GetAsync($"{nameof(LoadProcessesDataList)}-{address}", async () => + { + var data = await graphqlClient.GetAoProcessesForAddress(address); + return new WalletProcessDataViewModel() { Address = address, Processes = data }; + }, TimeSpan.FromMinutes(1)); + + + }, (x) => { SelectedProcessData.Data = x; }); + } + public async Task LoadWalletList(bool force = false) { @@ -375,6 +400,7 @@ private async Task TryAddTokenIds(List allTokenIds) partial void OnSelectedAddressChanged(string? value) { SelectWallet(value); + LoadSelectedWalletProcessData(); if (value != null) this.AddToLog(ActivityLogType.ViewAddress, value);