Skip to content

Commit

Permalink
Loading fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Mar 29, 2024
1 parent 9df55b2 commit 6d419f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/aoWebWallet/Pages/WalletDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@
</MudStack>
</MudItem>

@{
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)
{
<MudItem xs12 sm="4">
<MudStack>
Expand All @@ -187,7 +184,7 @@


<MudTimeline TimelinePosition="TimelinePosition.Left">
@foreach (var process in processes.Data.Processes)
@foreach (var process in BindingContext.SelectedProcessData.Data.Processes)
{
var linkUrl = $"/wallet/{process.Id}";
<MudStack Row=true>
Expand Down
3 changes: 2 additions & 1 deletion src/aoWebWallet/Pages/WalletDetail.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ protected override void OnInitialized()
WatchDataLoaderVM(BindingContext.WalletList);
WatchDataLoaderVM(BindingContext.BalanceDataList);
WatchDataLoaderVM(BindingContext.TokenTransferList);
WatchDataLoaderVM(BindingContext.SelectedProcessData);

base.OnInitialized();
}
Expand All @@ -34,7 +35,7 @@ protected override void OnParametersSet()

protected override async Task LoadDataAsync()
{
await BindingContext.LoadTokenList();
BindingContext.LoadTokenList();

Check warning on line 38 in src/aoWebWallet/Pages/WalletDetail.razor.cs

View workflow job for this annotation

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

//if (!string.IsNullOrEmpty(Address))
//{
Expand Down
26 changes: 26 additions & 0 deletions src/aoWebWallet/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using aoWebWallet.Models;
using aoWebWallet.Pages;
using aoWebWallet.Services;
using ArweaveAO;
using ArweaveAO.Models.Token;
Expand Down Expand Up @@ -75,6 +76,7 @@ public partial class MainViewModel : ObservableRecipient
public DataLoaderViewModel<List<TokenTransfer>> TokenTransferList { get; set; } = new();
public DataLoaderViewModel<TokenTransfer> SelectedTransaction { get; set; } = new();
public DataLoaderViewModel<List<DataLoaderViewModel<WalletProcessDataViewModel>>> ProcessesDataList { get; set; } = new();
public DataLoaderViewModel<WalletProcessDataViewModel> SelectedProcessData { get; set; } = new();


//TODO:
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -375,6 +400,7 @@ private async Task TryAddTokenIds(List<string?> allTokenIds)
partial void OnSelectedAddressChanged(string? value)
{
SelectWallet(value);
LoadSelectedWalletProcessData();

if (value != null)
this.AddToLog(ActivityLogType.ViewAddress, value);
Expand Down

0 comments on commit 6d419f1

Please sign in to comment.