mirror of
https://github.com/status-im/nft-faucet.git
synced 2025-02-24 20:48:24 +00:00
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using NftFaucetRadzen.Models;
|
|
using NftFaucetRadzen.Plugins.NetworkPlugins;
|
|
using NftFaucetRadzen.Plugins.ProviderPlugins;
|
|
using NftFaucetRadzen.Services;
|
|
|
|
namespace NftFaucetRadzen.Components;
|
|
|
|
public abstract class BasicLayout : LayoutComponentBase
|
|
{
|
|
[Inject]
|
|
protected NavigationManager UriHelper { get; set; }
|
|
|
|
[Inject]
|
|
protected ScopedAppState AppState { get; set; }
|
|
|
|
[Inject]
|
|
protected RefreshMediator RefreshMediator { get; set; }
|
|
|
|
[Inject]
|
|
protected PluginLoader PluginLoader { get; set; }
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
PluginLoader.EnsurePluginsLoaded();
|
|
AppState.Storage.Networks = PluginLoader.NetworkPlugins.SelectMany(x => x.Networks).Where(x => x != null).ToArray();
|
|
AppState.Storage.Providers = PluginLoader.ProviderPlugins.SelectMany(x => x.Providers).Where(x => x != null).ToArray();
|
|
AppState.Storage.Contracts = AppState.Storage.Networks.SelectMany(x => x.DeployedContracts).Where(x => x != null).ToArray();
|
|
|
|
RefreshMediator.StateChanged += async () => await InvokeAsync(StateHasChangedSafe);
|
|
}
|
|
|
|
protected void StateHasChangedSafe()
|
|
{
|
|
try
|
|
{
|
|
InvokeAsync(StateHasChanged);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// ignored
|
|
}
|
|
}
|
|
}
|