From 15511a57195b73c7b209d48d7b53298f40fd5bfb Mon Sep 17 00:00:00 2001 From: Michiel Post Date: Sun, 23 Jun 2024 14:08:21 +0200 Subject: [PATCH] Added navigate back option after send action --- src/aoWebWallet/Pages/ActionPage.razor | 39 +++++++++++++++++++++----- src/aoWebWallet/Program.cs | 9 +++++- src/aoWebWallet/aoWebWallet.csproj | 1 + 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/aoWebWallet/Pages/ActionPage.razor b/src/aoWebWallet/Pages/ActionPage.razor index 718a8d6..56cdfc4 100644 --- a/src/aoWebWallet/Pages/ActionPage.razor +++ b/src/aoWebWallet/Pages/ActionPage.razor @@ -7,6 +7,8 @@ @inject TokenDataService dataService @inject TransactionService transactionService; @inject WalletDetailViewModel WalletDetailViewModel +@using Soenneker.Blazor.Utils.Navigation.Abstract +@inject INavigationUtil NavigationUtil @Program.PageTitlePostFix @@ -16,7 +18,7 @@ - @if(readOnly) + @if (readOnly) { Please review your transaction: } @@ -25,6 +27,10 @@ @if (!readOnly && !string.IsNullOrEmpty(BindingContext.ActiveWalletAddress)) { + if (NavigationUtil.CanNavigateBack) + { + Back + } Preview @validation } @@ -47,14 +53,26 @@ } @* - Learn More - *@ + Learn More + *@ } + if (NavigationUtil.CanNavigateBack) + { + Back + } Cancel Submit } + else if (transactionService.LastTransaction.DataLoader.LoadingState == LoadingState.None && string.IsNullOrEmpty(transactionService.LastTransaction.Data?.Id)) + { + if (NavigationUtil.CanNavigateBack) + { + Back + } + } + @if (transactionService.LastTransaction.DataLoader != null) { @@ -69,7 +87,14 @@ - Return to wallet + if (NavigationUtil.CanNavigateBack) + { + Back + } + else + { + Return to wallet + } @* View Transaction *@ } } @@ -80,7 +105,7 @@ @code { private string? validation; - + private bool readOnly = false; private bool started = false; @@ -144,7 +169,7 @@ return; var wallet = BindingContext.WalletList.Data.Where(x => x.Address == BindingContext.ActiveWallet?.Address).FirstOrDefault(); - if(wallet == null) + if (wallet == null) { if (BindingContext.ActiveWallet?.Address == BindingContext.ActiveWalletAddress) { @@ -162,6 +187,6 @@ await transactionService.SendAction(wallet, ownerWallet, AoAction); } - + } diff --git a/src/aoWebWallet/Program.cs b/src/aoWebWallet/Program.cs index b2bf742..759fddc 100644 --- a/src/aoWebWallet/Program.cs +++ b/src/aoWebWallet/Program.cs @@ -16,6 +16,7 @@ using aoWebWallet.Models; using ArweaveAO.Models; using MudExtensions.Services; +using Soenneker.Blazor.Utils.Navigation.Registrars; namespace aoWebWallet { @@ -72,7 +73,11 @@ public static async Task Main(string[] args) ConfigureServices(builder.Services, builder.HostEnvironment.BaseAddress); - await builder.Build().RunAsync(); + WebAssemblyHost host = builder.Build(); + + host.Services.WarmupNavigation(); + + await host.RunAsync(); } private static void ConfigureServices(IServiceCollection services, string baseAddress) @@ -122,6 +127,8 @@ private static void ConfigureServices(IServiceCollection services, string baseAd services.AddClipboard(); + services.AddNavigationUtil(); + //Options services.AddSingleton(new GraphqlConfig()); services.AddSingleton(new GatewayConfig()); diff --git a/src/aoWebWallet/aoWebWallet.csproj b/src/aoWebWallet/aoWebWallet.csproj index 9679102..5399e2d 100644 --- a/src/aoWebWallet/aoWebWallet.csproj +++ b/src/aoWebWallet/aoWebWallet.csproj @@ -23,6 +23,7 @@ +