Add TutorialDone settings flag (#177)

This commit is contained in:
Leendert de Borst
2024-10-28 13:36:55 +01:00
parent 50c3c64db6
commit 0631daf61b
7 changed files with 55 additions and 53 deletions

View File

@@ -17,7 +17,7 @@
<EditForm Model="Model" OnValidSubmit="CreateIdentity">
<DataAnnotationsValidator />
<div class="mb-4">
<EditFormRow Id="serviceName" Label="Service Name" @bind-Value="Model.ServiceName"></EditFormRow>
<EditFormRow Id="serviceName" Label="Service Name" Placeholder="E.g. Facebook" @bind-Value="Model.ServiceName"></EditFormRow>
<ValidationMessage For="() => Model.ServiceName"/>
</div>
<div class="mb-4">

View File

@@ -35,7 +35,7 @@ else
<h3 class="mb-4 text-xl font-semibold dark:text-white">Service</h3>
<div class="grid gap-6">
<div class="col-span-6 sm:col-span-3">
<EditFormRow Id="service-name" Label="Service Name" @bind-Value="Obj.ServiceName"></EditFormRow>
<EditFormRow Id="service-name" Label="Service Name" Placeholder="E.g. Facebook" @bind-Value="Obj.ServiceName"></EditFormRow>
<ValidationMessage For="() => Obj.ServiceName"/>
</div>
<div class="col-span-6 sm:col-span-3">

View File

@@ -53,7 +53,7 @@
GlobalNotificationService.AddErrorMessage("Failed to load credentials.", true);
return;
}
if (credentialListEntries.Count == 0)
if (credentialListEntries.Count == 0 && !DbService.Settings.TutorialDone)
{
// Redirect to welcome page.
NavigationManager.NavigateTo("/welcome");

View File

@@ -91,27 +91,27 @@
/// <summary>
/// Updates the default email domain.
/// </summary>
private void UpdateDefaultEmailDomain()
private async Task UpdateDefaultEmailDomain()
{
DbService.Settings.DefaultEmailDomain = DefaultEmailDomain;
await DbService.Settings.SetDefaultEmailDomain(DefaultEmailDomain);
StateHasChanged();
}
/// <summary>
/// Updates the auto email refresh setting.
/// </summary>
private void UpdateAutoEmailRefresh()
private async Task UpdateAutoEmailRefresh()
{
DbService.Settings.AutoEmailRefresh = AutoEmailRefresh;
await DbService.Settings.SetAutoEmailRefresh(AutoEmailRefresh);
StateHasChanged();
}
/// <summary>
/// Updates the auto email refresh setting.
/// </summary>
private void UpdateDefaultIdentityLanguage()
private async Task UpdateDefaultIdentityLanguage()
{
DbService.Settings.DefaultIdentityLanguage = DefaultIdentityLanguage;
await DbService.Settings.SetDefaultIdentityLanguage(DefaultIdentityLanguage);
StateHasChanged();
}
}

View File

@@ -48,20 +48,6 @@
</div>
break;
case TutorialStep.SecureEnvironment:
<div class="space-y-4">
<p class="text-gray-600 dark:text-gray-400">
AliasVault is built with security and privacy in mind:
</p>
<ol class="list-decimal list-inside space-y-2 text-gray-600 dark:text-gray-400">
<li>All your data is encrypted in your browser with your master password</li>
<li>Emails are stored encrypted on the server and are only readable by you</li>
<li>Your master password never leaves your device</li>
<li>The source-code is open-source and available on GitHub</li>
</ol>
</div>
break;
case TutorialStep.SecurityTips:
<div class="space-y-4">
<h3 class="text-2xl font-bold text-gray-900 dark:text-white">Privacy & Security Tips</h3>
@@ -144,7 +130,6 @@
{
TutorialStep.Welcome => "Welcome to AliasVault",
TutorialStep.HowAliasVaultWorks => "How AliasVault Works",
TutorialStep.SecureEnvironment => "Secure Environment",
TutorialStep.SecurityTips => "Security Tips",
TutorialStep.CreateFirstIdentity => "Get Started",
_ => "Tutorial"
@@ -173,8 +158,7 @@
_currentStep = _currentStep switch
{
TutorialStep.Welcome => TutorialStep.HowAliasVaultWorks,
TutorialStep.HowAliasVaultWorks => TutorialStep.SecureEnvironment,
TutorialStep.SecureEnvironment => TutorialStep.SecurityTips,
TutorialStep.HowAliasVaultWorks => TutorialStep.SecurityTips,
TutorialStep.SecurityTips => TutorialStep.CreateFirstIdentity,
_ => _currentStep
};
@@ -185,9 +169,9 @@
NavigationManager.NavigateTo("credentials/create");
}
private void FinishTutorial()
private async Task FinishTutorial()
{
DbService.Settings.TutorialDone = true;
await DbService.Settings.SetTutorialDoneAsync(true);
NavigationManager.NavigateTo("credentials");
}

View File

@@ -28,9 +28,9 @@ public sealed class DbService : IDisposable
private readonly HttpClient _httpClient;
private readonly DbServiceState _state = new();
private readonly Config _config;
private readonly SettingsService _settingsService = new();
private readonly ILogger<DbService> _logger;
private readonly GlobalNotificationService _globalNotificationService;
private SettingsService _settingsService = new();
private SqliteConnection? _sqlConnection;
private AliasClientDbContext _dbContext;
private long _vaultRevisionNumber;
@@ -412,6 +412,9 @@ public sealed class DbService : IDisposable
_state.UpdateState(DbServiceState.DatabaseStatus.Uninitialized);
_isSuccessfullyInitialized = false;
// Reset settings.
_settingsService = new();
return (_sqlConnection, _dbContext);
}

View File

@@ -27,40 +27,55 @@ public sealed class SettingsService
private bool _initialized;
/// <summary>
/// Gets or sets a value indicating whether the tutorial has been completed.
/// Gets the DefaultEmailDomain setting.
/// </summary>
public bool TutorialDone
{
get => GetSetting("TutorialDone", false);
set => SetSettingAsync("TutorialDone", value).GetAwaiter().GetResult();
}
/// <returns>Default email domain as string.</returns>
public string DefaultEmailDomain => GetSetting("DefaultEmailDomain");
/// <summary>
/// Gets or sets the DefaultEmailDomain setting.
/// Gets a value indicating whether email refresh should be done automatically on the credentials page.
/// </summary>
public string DefaultEmailDomain
{
get => GetSetting("DefaultEmailDomain");
set => SetSettingAsync("DefaultEmailDomain", value).GetAwaiter().GetResult();
}
/// <returns>AutoEmailRefresh setting as string.</returns>
public bool AutoEmailRefresh => GetSetting("AutoEmailRefresh", true);
/// <summary>
/// Gets or sets a value indicating whether email refresh should be done automatically on the credentials page.
/// Gets the DefaultIdentityLanguage setting.
/// </summary>
public bool AutoEmailRefresh
{
get => GetSetting("AutoEmailRefresh", true);
set => SetSettingAsync("AutoEmailRefresh", value).GetAwaiter().GetResult();
}
/// <returns>Default identity language as two-letter code.</returns>
public string DefaultIdentityLanguage => GetSetting<string>("DefaultIdentityLanguage", "en")!;
/// <summary>
/// Gets or sets the DefaultIdentityLanguage setting.
/// Gets a value indicating whether the tutorial has been completed.
/// </summary>
public string DefaultIdentityLanguage
{
get => GetSetting<string>("DefaultIdentityLanguage", "en")!;
set => SetSettingAsync("DefaultIdentityLanguage", value).GetAwaiter().GetResult();
}
public bool TutorialDone => GetSetting("TutorialDone", false);
/// <summary>
/// Sets the DefaultEmailDomain setting.
/// </summary>
/// <param name="value">The new DefaultEmailDomain setting.</param>
/// <returns>Task.</returns>
public Task SetDefaultEmailDomain(string value) => SetSettingAsync("DefaultEmailDomain", value);
/// <summary>
/// Sets the AutoEmailRefresh setting as a string.
/// </summary>
/// <param name="value">The new value.</param>
/// <returns>Task.</returns>
public Task SetAutoEmailRefresh(bool value) => SetSettingAsync("AutoEmailRefresh", value);
/// <summary>
/// Sets the DefaultIdentityLanguage setting.
/// </summary>
/// <param name="value">The new value.</param>
/// <returns>Task.</returns>
public Task SetDefaultIdentityLanguage(string value) => SetSettingAsync("DefaultIdentityLanguage", value);
/// <summary>
/// Sets the TutorialDone setting.
/// </summary>
/// <param name="value">Value to set.</param>
/// <returns>Task.</returns>
public Task SetTutorialDoneAsync(bool value) => SetSettingAsync("TutorialDone", value);
/// <summary>
/// Initializes the settings service asynchronously.