Skip to content

Commit

Permalink
Fix edit wallet name
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed May 15, 2024
1 parent 3db77e2 commit c5e869f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/aoWebWallet/Services/StorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public async ValueTask SaveWallet (Wallet wallet)
if(existing != null)
list.Remove(existing);

list.Add(wallet);
list.Insert(0,wallet);

await SaveWalletList(list);
}
Expand Down
25 changes: 20 additions & 5 deletions src/aoWebWallet/Shared/EditWalletComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

<MudPaper Class="pa-8">
<MudStack Spacing="2">
<MudTextField @bind-Value="Wallet.Address" ReadOnly="@IsReadOnly" Required="true" RequiredError="Input a wallet address" Mask="@(new RegexMask("^[a-zA-Z0-9_\\-]{0,43}$"))" Label="Wallet Address" Variant="Variant.Text"></MudTextField>
<MudTextField @bind-Value="Address" ReadOnly="@IsReadOnly" Required="true" RequiredError="Input a wallet address" Mask="@(new RegexMask("^[a-zA-Z0-9_\\-]{0,43}$"))" Label="Wallet Address" Variant="Variant.Text"></MudTextField>
<MudText Color="Color.Secondary">@Progress</MudText>
<MudTextField @bind-Value="Wallet.Name" Label="Wallet Name" Variant="Variant.Text"></MudTextField>
<MudTextField @bind-Value="Name" Label="Wallet Name" Variant="Variant.Text"></MudTextField>

<div Class="d-w-100 d-flex justify-end mt-2">
<MudButton OnClick="Submit" Color="Color.Primary" Variant="Variant.Filled">
Expand All @@ -25,10 +25,20 @@
[CascadingParameter] MudDialogInstance? MudDialog { get; set; }

public string? Progress { get; set; }
public string Address { get; set; } = string.Empty;
public string? Name { get; set; }

public bool IsReadOnly => !Wallet.IsReadOnly;
public bool IsReadOnly => !string.IsNullOrEmpty(Wallet.Address);


protected override void OnParametersSet()
{
Address = Wallet.Address;
Name = Wallet.Name;

base.OnParametersSet();
}

protected override void OnInitialized()
{
base.OnInitialized();
Expand All @@ -44,16 +54,21 @@
// return false;
// }
if (string.IsNullOrWhiteSpace(Wallet.Address) || Wallet.Address.Length != 43)
if (string.IsNullOrWhiteSpace(Address) || Address.Length != 43)
{
Progress = "Length must be 43 characters.";
StateHasChanged();
return false;
}

Wallet.Name = Name;
Wallet.Address = Address;

await BindingContext.SaveWallet(Wallet);

Snackbar.Add($"Address saved ({Wallet.Address})", Severity.Info);
StateHasChanged();

Snackbar.Add($"Address saved {Wallet.Name} ({Wallet.Address})", Severity.Info);

MudDialog?.Close(true);

Expand Down
4 changes: 2 additions & 2 deletions src/aoWebWallet/aoWebWallet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="BlazorWasmPreRendering.Build" Version="4.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.5" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit c5e869f

Please sign in to comment.