mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-23 03:58:23 +00:00
Fix navigation
This commit is contained in:
parent
60db7a4720
commit
02282313af
20
NftFaucet/Extensions/NavigationManagerExtensions.cs
Normal file
20
NftFaucet/Extensions/NavigationManagerExtensions.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace NftFaucet.Extensions;
|
||||
|
||||
public static class NavigationManagerExtensions
|
||||
{
|
||||
public static void NavigateToRelative(this NavigationManager uriHelper, string relativePath)
|
||||
{
|
||||
var newUri = uriHelper.BaseUri;
|
||||
if (!newUri.EndsWith("/"))
|
||||
newUri += "/";
|
||||
|
||||
if (relativePath.StartsWith("/"))
|
||||
relativePath = relativePath.Substring(1);
|
||||
|
||||
newUri += relativePath;
|
||||
|
||||
uriHelper.NavigateTo(newUri);
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NftFaucet.Extensions;
|
||||
|
||||
namespace NftFaucet.Models;
|
||||
|
||||
@ -59,7 +60,7 @@ public class NavigationWrapper
|
||||
var previousStep = CurrentStep - 1;
|
||||
_beforeGoBack = null;
|
||||
_beforeGoForward = null;
|
||||
_uriHelper.NavigateTo("/step" + previousStep);
|
||||
_uriHelper.NavigateToRelative("/step" + previousStep);
|
||||
}
|
||||
|
||||
public async Task GoForward()
|
||||
@ -74,6 +75,6 @@ public class NavigationWrapper
|
||||
var nextStep = CurrentStep + 1;
|
||||
_beforeGoBack = null;
|
||||
_beforeGoForward = null;
|
||||
_uriHelper.NavigateTo("/step" + nextStep);
|
||||
_uriHelper.NavigateToRelative("/step" + nextStep);
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NftFaucet.Components;
|
||||
using NftFaucet.Extensions;
|
||||
|
||||
namespace NftFaucet.Pages;
|
||||
|
||||
@ -9,7 +10,7 @@ public class ConnectMetamaskComponent : BasicComponent
|
||||
if (await Metamask.IsConnected())
|
||||
{
|
||||
await Metamask.RefreshAddress();
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +19,7 @@ public class ConnectMetamaskComponent : BasicComponent
|
||||
var isConnected = await Metamask.Connect();
|
||||
if (isConnected)
|
||||
{
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NftFaucet.Components;
|
||||
using NftFaucet.Extensions;
|
||||
|
||||
namespace NftFaucet.Pages;
|
||||
|
||||
@ -6,6 +7,6 @@ public class IndexComponent : BasicComponent
|
||||
{
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
UriHelper.NavigateTo(await Metamask.IsReady() ? "/step1" : "/connect-metamask");
|
||||
UriHelper.NavigateToRelative(await Metamask.IsReady() ? "/step1" : "/connect-metamask");
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ using AntDesign;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NftFaucet.Components;
|
||||
using NftFaucet.Constants;
|
||||
using NftFaucet.Extensions;
|
||||
using NftFaucet.Models.Enums;
|
||||
|
||||
namespace NftFaucet.Pages;
|
||||
@ -24,7 +25,7 @@ public class Step1Component : BasicComponent
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!await AppState.Metamask.IsReady())
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
|
||||
AppState.Navigation.SetForwardHandler(ForwardHandler);
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Step2Component : BasicComponent
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!await AppState.Metamask.IsReady() || AppState.Storage.IpfsImageUrl == null)
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
|
||||
AppState.Navigation.SetForwardHandler(ForwardHandler);
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NftFaucet.Components;
|
||||
using NftFaucet.Extensions;
|
||||
using NftFaucet.Models;
|
||||
|
||||
namespace NftFaucet.Pages;
|
||||
@ -13,7 +14,7 @@ public class Step3Component : BasicComponent
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!await AppState.Metamask.IsReady() || string.IsNullOrEmpty(AppState.Storage.TokenUrl))
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
|
||||
AppState.Navigation.SetForwardHandler(ForwardHandler);
|
||||
AppState.Storage.DestinationAddress = AppState.Metamask.Address;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using NftFaucet.Components;
|
||||
using NftFaucet.Extensions;
|
||||
using NftFaucet.Models.Enums;
|
||||
using NftFaucet.Services;
|
||||
|
||||
@ -20,7 +21,7 @@ public class Step4Component : BasicComponent
|
||||
{
|
||||
if (!await AppState.Metamask.IsReady() || string.IsNullOrEmpty(AppState.Storage.DestinationAddress))
|
||||
{
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -46,6 +47,6 @@ public class Step4Component : BasicComponent
|
||||
protected void Reset()
|
||||
{
|
||||
AppState.Reset();
|
||||
UriHelper.NavigateTo("/");
|
||||
UriHelper.NavigateToRelative("/");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user