Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Update email field UX (#137)

Leendert de Borstf8493f2ff636
diff --git a/src/AliasVault.Client/Main/Components/Email/RecentEmails.razor b/src/AliasVault.Client/Main/Components/Email/RecentEmails.razor
index c84b57a7a..f92666623 100644
--- a/src/AliasVault.Client/Main/Components/Email/RecentEmails.razor
+++ b/src/AliasVault.Client/Main/Components/Email/RecentEmails.razor
@@ -147,7 +147,7 @@
/// </summary>
private bool IsSpamOkDomain(string email)
{
- return Config.PublicEmailDomains.Any(x => email.EndsWith(x));
+ return Config.PublicEmailDomains.Exists(x => email.EndsWith(x));
}
/// <summary>
@@ -290,7 +290,7 @@
case HttpStatusCode.Unauthorized:
throw new UnauthorizedAccessException(errorResponse?.Message);
default:
- throw new ApplicationException(errorResponse?.Message);
+ throw new WebException(errorResponse?.Message);
}
}
}
diff --git a/src/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor b/src/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor
index b7e022f31..f64af69c2 100644
--- a/src/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor
+++ b/src/AliasVault.Client/Main/Components/Forms/EditEmailFormRow.razor
@@ -15,12 +15,21 @@
</div>
<div class="mt-2">
- <button type="button" class="text-sm text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200" @onclick="TogglePopup">
- @(IsCustomDomain ? "Use domain chooser" : "Enter custom domain")
- </button>
+ @if (IsCustomDomain)
+ {
+ <button type="button" class="text-sm text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200" @onclick="TogglePopup">
+ Use domain chooser
+ </button>
+ }
+ else
+ {
+ <button type="button" class="text-sm text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-200" @onclick="ToggleCustomDomain">
+ Enter custom domain
+ </button>
+ }
</div>
-@if (_isPopupVisible)
+@if (IsPopupVisible)
{
<div class="fixed inset-0 bg-gray-600 bg-opacity-50 z-30 overflow-y-auto h-full w-full" @onclick="ClosePopup">
<div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white dark:bg-gray-800" @onclick:stopPropagation>
@@ -84,7 +93,7 @@
private bool IsCustomDomain { get; set; } = false;
private string LocalPart { get; set; } = string.Empty;
private string SelectedDomain = string.Empty;
- private bool _isPopupVisible = false;
+ private bool IsPopupVisible = false;
private List<string> PrivateDomains => Config.PrivateEmailDomains;
private List<string> PublicDomains => Config.PublicEmailDomains;
@@ -104,7 +113,19 @@
{
base.OnParametersSet();
- SelectedDomain = Value.Contains('@') ? Value.Split('@')[1] : (ShowPrivateDomains ? PrivateDomains[0] : PublicDomains[0]);
+ if (Value.Contains('@'))
+ {
+ SelectedDomain = Value.Split('@')[1];
+ }
+ else if (ShowPrivateDomains)
+ {
+ SelectedDomain = PrivateDomains[0];
+ }
+ else
+ {
+ SelectedDomain = PublicDomains[0];
+ }
+
IsCustomDomain = !PublicDomains.Contains(SelectedDomain) && !PrivateDomains.Contains(SelectedDomain);
if (IsCustomDomain)
{
@@ -116,16 +137,6 @@
}
}
- private string FullEmail
- {
- get => Value;
- set
- {
- Value = value;
- ValueChanged.InvokeAsync(Value);
- }
- }
-
private async Task OnLocalPartChanged(ChangeEventArgs e)
{
string newLocalPart = e.Value?.ToString() ?? string.Empty;
@@ -145,16 +156,18 @@
private void TogglePopup()
{
- _isPopupVisible = !_isPopupVisible;
+ IsPopupVisible = !IsPopupVisible;
}
private void ClosePopup()
{
- _isPopupVisible = false;
+ IsPopupVisible = false;
}
private async Task SelectDomain(string domain)
{
+ // Remove the '@' symbol and everything after if it exists.
+ LocalPart = LocalPart.Contains('@') ? LocalPart.Split('@')[0] : LocalPart;
Value = $"{LocalPart}@{domain}";
await ValueChanged.InvokeAsync(Value);
IsCustomDomain = false;