Couple fixes for beta.

This commit is contained in:
Burak Kaan Köse
2026-04-16 13:45:11 +02:00
parent 65f7e0236a
commit 784144cd13
12 changed files with 217 additions and 33 deletions
@@ -220,7 +220,12 @@ public partial class AccountSetupProgressPageViewModel : MailBaseViewModel
_createdAccount.Base64ProfilePictureData = profileResult.ProfileInformation.Base64ProfilePictureData;
if (!string.IsNullOrEmpty(profileResult.ProfileInformation.AccountAddress))
{
if (await _accountService.AccountAddressExistsAsync(profileResult.ProfileInformation.AccountAddress, _createdAccount.Id).ConfigureAwait(false))
throw new InvalidOperationException(Translator.DialogMessage_AccountAddressExistsMessage);
_createdAccount.Address = profileResult.ProfileInformation.AccountAddress;
}
await _accountService.UpdateProfileInformationAsync(_createdAccount.Id, profileResult.ProfileInformation);
}
@@ -34,6 +34,7 @@ public partial class ImapCalDavSettingsPageViewModel : MailBaseViewModel
private Guid _editingAccountId;
private SpecialImapProvider _editingSpecialImapProvider;
private TaskCompletionSource<ImapCalDavSetupResult> _completionSource;
private AccountCreationDialogResult _accountCreationContext;
private bool _isCompletionFinalized;
private bool _localOnlyInfoShown;
@@ -283,6 +284,7 @@ public partial class ImapCalDavSettingsPageViewModel : MailBaseViewModel
_pageMode = context.Mode;
_editingAccountId = context.AccountId;
_completionSource = context.CompletionSource;
_accountCreationContext = context.AccountCreationDialogResult;
_isCompletionFinalized = false;
_localOnlyInfoShown = false;
SelectedSetupTabIndex = 0;
@@ -406,6 +408,13 @@ public partial class ImapCalDavSettingsPageViewModel : MailBaseViewModel
ValidateImapSettings(serverInformation);
ValidateCalendarModeSpecificSettings(serverInformation);
var excludedAccountId = _pageMode == ImapCalDavSettingsPageMode.Edit
? _editingAccountId
: (Guid?)null;
if (!await ValidateAccountUniquenessAsync(excludedAccountId).ConfigureAwait(false))
return;
await ValidateImapConnectivityAsync(serverInformation);
IsImapValidationSucceeded = true;
@@ -770,6 +779,34 @@ public partial class ImapCalDavSettingsPageViewModel : MailBaseViewModel
Messenger.Send(new BackBreadcrumNavigationRequested());
}
private async Task<bool> ValidateAccountUniquenessAsync(Guid? excludedAccountId)
{
var accountName = (_pageMode == ImapCalDavSettingsPageMode.Create || _pageMode == ImapCalDavSettingsPageMode.Wizard)
? _accountCreationContext?.AccountName
: null;
if (!string.IsNullOrWhiteSpace(accountName) &&
await _accountService.AccountNameExistsAsync(accountName, excludedAccountId).ConfigureAwait(false))
{
_mailDialogService.InfoBarMessage(
Translator.DialogMessage_AccountExistsTitle,
Translator.DialogMessage_AccountNameExistsMessage,
InfoBarMessageType.Error);
return false;
}
if (await _accountService.AccountAddressExistsAsync(EmailAddress, excludedAccountId).ConfigureAwait(false))
{
_mailDialogService.InfoBarMessage(
Translator.DialogMessage_AccountExistsTitle,
Translator.DialogMessage_AccountAddressExistsMessage,
InfoBarMessageType.Error);
return false;
}
return true;
}
private async Task SaveEditFlowAsync(CustomServerInformation serverInformation)
{
var account = await _accountService.GetAccountAsync(_editingAccountId).ConfigureAwait(false);
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
@@ -16,6 +17,8 @@ namespace Wino.Mail.ViewModels;
public partial class ProviderSelectionPageViewModel : MailBaseViewModel
{
private readonly IAccountService _accountService;
private readonly IDialogServiceBase _dialogService;
private readonly IProviderService _providerService;
private readonly INewThemeService _themeService;
@@ -53,10 +56,14 @@ public partial class ProviderSelectionPageViewModel : MailBaseViewModel
public bool IsInitialSynchronizationWarningVisible => SelectedInitialSynchronizationRange?.IsEverything == true;
public ProviderSelectionPageViewModel(
IAccountService accountService,
IDialogServiceBase dialogService,
IProviderService providerService,
INewThemeService themeService,
WelcomeWizardContext wizardContext)
{
_accountService = accountService;
_dialogService = dialogService;
_providerService = providerService;
_themeService = themeService;
WizardContext = wizardContext;
@@ -107,10 +114,19 @@ public partial class ProviderSelectionPageViewModel : MailBaseViewModel
}
[RelayCommand]
private void Proceed()
private async Task ProceedAsync()
{
if (!CanProceed) return;
if (await _accountService.AccountNameExistsAsync(AccountName).ConfigureAwait(false))
{
await _dialogService.ShowMessageAsync(
Translator.DialogMessage_AccountNameExistsMessage,
Translator.DialogMessage_AccountExistsTitle,
WinoCustomMessageDialogIcon.Warning);
return;
}
// Persist to wizard context
WizardContext.SelectedProvider = SelectedProvider;
WizardContext.AccountName = AccountName?.Trim();
@@ -15,6 +15,8 @@ namespace Wino.Mail.ViewModels;
public partial class SpecialImapCredentialsPageViewModel : MailBaseViewModel
{
private readonly IAccountService _accountService;
private readonly IDialogServiceBase _dialogService;
private static readonly Dictionary<SpecialImapProvider, string> AppPasswordHelpLinks = new()
{
{ SpecialImapProvider.iCloud, "https://support.apple.com/en-us/102654" },
@@ -56,9 +58,13 @@ public partial class SpecialImapCredentialsPageViewModel : MailBaseViewModel
: Translator.ProviderSelection_CalendarMode_CalDavDescription_Yahoo;
public SpecialImapCredentialsPageViewModel(
IAccountService accountService,
IDialogServiceBase dialogService,
INativeAppService nativeAppService,
WelcomeWizardContext wizardContext)
{
_accountService = accountService;
_dialogService = dialogService;
_nativeAppService = nativeAppService;
WizardContext = wizardContext;
}
@@ -98,10 +104,19 @@ public partial class SpecialImapCredentialsPageViewModel : MailBaseViewModel
}
[RelayCommand]
private void Proceed()
private async Task ProceedAsync()
{
if (!CanProceed) return;
if (await _accountService.AccountAddressExistsAsync(EmailAddress).ConfigureAwait(false))
{
await _dialogService.ShowMessageAsync(
Translator.DialogMessage_AccountAddressExistsMessage,
Translator.DialogMessage_AccountExistsTitle,
WinoCustomMessageDialogIcon.Warning);
return;
}
WizardContext.DisplayName = DisplayName?.Trim();
WizardContext.EmailAddress = EmailAddress?.Trim();
WizardContext.AppSpecificPassword = AppSpecificPassword?.Trim();