diff --git a/Wino.Core.Domain/Enums/WinoPage.cs b/Wino.Core.Domain/Enums/WinoPage.cs index fd3bd7d4..9837a3c8 100644 --- a/Wino.Core.Domain/Enums/WinoPage.cs +++ b/Wino.Core.Domain/Enums/WinoPage.cs @@ -41,7 +41,6 @@ public enum WinoPage EmailTemplatesPage, CreateEmailTemplatePage, StoragePage, - WinoAccountManagementPage, WelcomePageV2, WelcomeHostPage, ProviderSelectionPage, diff --git a/Wino.Core.Domain/Interfaces/IMailDialogService.cs b/Wino.Core.Domain/Interfaces/IMailDialogService.cs index 0e070f15..7b688bd4 100644 --- a/Wino.Core.Domain/Interfaces/IMailDialogService.cs +++ b/Wino.Core.Domain/Interfaces/IMailDialogService.cs @@ -87,9 +87,4 @@ public interface IMailDialogService : IDialogServiceBase /// Contact information. Null if canceled. Task ShowEditContactDialogAsync(AccountContact? contact = null); - Task ShowWinoAccountRegistrationDialogAsync(); - - Task ShowWinoAccountLoginDialogAsync(); - - Task ShowWinoAccountExportDialogAsync(); } diff --git a/Wino.Core.Domain/Interfaces/IPreferencesService.cs b/Wino.Core.Domain/Interfaces/IPreferencesService.cs index 12363ff2..adc931a2 100644 --- a/Wino.Core.Domain/Interfaces/IPreferencesService.cs +++ b/Wino.Core.Domain/Interfaces/IPreferencesService.cs @@ -70,12 +70,10 @@ public interface IPreferencesService : INotifyPropertyChanged /// /// Setting: Whether the Wino account profile button in the shell title bar should be hidden. /// - bool IsWinoAccountButtonHidden { get; set; } /// /// Setting: Whether AI actions panels and their toggle buttons should be hidden. /// - bool IsAiActionsPanelHidden { get; set; } /// /// Setting: Default target language code used for AI translation actions. diff --git a/Wino.Core.Domain/Models/Settings/SettingsNavigationItemInfo.cs b/Wino.Core.Domain/Models/Settings/SettingsNavigationItemInfo.cs index 6c135fa0..ef04994e 100644 --- a/Wino.Core.Domain/Models/Settings/SettingsNavigationItemInfo.cs +++ b/Wino.Core.Domain/Models/Settings/SettingsNavigationItemInfo.cs @@ -36,11 +36,6 @@ public static class SettingsNavigationInfoProvider manageAccountsDescription, "\uE77B", searchKeywords: Translator.SettingsSearch_ManageAccounts_Keywords), - new(WinoPage.WinoAccountManagementPage, - Translator.WinoAccount_SettingsSection_Title, - Translator.WinoAccount_SettingsSection_Description, - "\uE77B", - searchKeywords: string.Empty), new(null, Translator.SettingsOptions_GeneralSection, string.Empty, "\uE713", isSeparator: true), new(WinoPage.AppPreferencesPage, Translator.SettingsAppPreferences_Title, @@ -152,7 +147,6 @@ public static class SettingsNavigationInfoProvider WinoPage.SettingOptionsPage => Translator.MenuSettings, WinoPage.ManageAccountsPage => Translator.SettingsManageAccountSettings_Title, WinoPage.AccountManagementPage => Translator.SettingsManageAccountSettings_Title, - WinoPage.WinoAccountManagementPage => Translator.WinoAccount_SettingsSection_Title, WinoPage.PersonalizationPage => Translator.SettingsPersonalization_Title, WinoPage.AboutPage => Translator.SettingsAbout_Title, WinoPage.MessageListPage => Translator.SettingsMessageList_Title, diff --git a/Wino.Core.ViewModels/WinoAccountManagementPageViewModel.cs b/Wino.Core.ViewModels/WinoAccountManagementPageViewModel.cs deleted file mode 100644 index 2631579f..00000000 --- a/Wino.Core.ViewModels/WinoAccountManagementPageViewModel.cs +++ /dev/null @@ -1,632 +0,0 @@ -#nullable enable -using System; -using System.Collections.ObjectModel; -using System.Threading.Tasks; -using CommunityToolkit.Mvvm.ComponentModel; -using CommunityToolkit.Mvvm.Input; -using CommunityToolkit.Mvvm.Messaging; -using Wino.Core.Domain; -using Wino.Core.Domain.Entities.Shared; -using Wino.Core.Domain.Enums; -using Wino.Core.Domain.Interfaces; -using Wino.Core.Domain.Models.Accounts; -using Wino.Core.Domain.Models.Navigation; -using Wino.Core.ViewModels.Data; -using Wino.Mail.Api.Contracts.Common; -using Wino.Messaging.UI; - -namespace Wino.Core.ViewModels; - -public partial class WinoAccountManagementPageViewModel : CoreBaseViewModel, - IRecipient, - IRecipient, - IRecipient -{ - private readonly IWinoAccountProfileService _profileService; - private readonly IWinoAccountDataSyncService _syncService; - private readonly IMailDialogService _dialogService; - private readonly IStoreManagementService _storeManagementService; - private readonly WinoAddOnItemViewModel _aiPackAddOn; - private readonly WinoAddOnItemViewModel _unlimitedAccountsAddOn; - - public ObservableCollection AddOns { get; } = []; - - [ObservableProperty] - public partial bool IsBusy { get; set; } - - [ObservableProperty] - [NotifyPropertyChangedFor(nameof(IsSignedOut))] - public partial bool IsSignedIn { get; set; } - - [ObservableProperty] - public partial string AccountEmail { get; set; } = string.Empty; - - [ObservableProperty] - public partial string AccountStatusText { get; set; } = string.Empty; - - [ObservableProperty] - [NotifyCanExecuteChangedFor(nameof(PurchaseAddOnCommand))] - public partial bool IsCheckoutInProgress { get; set; } - - public bool IsSignedOut => !IsSignedIn; - - public WinoAccountManagementPageViewModel(IWinoAccountProfileService profileService, - IWinoAccountDataSyncService syncService, - IMailDialogService dialogService, - IStoreManagementService storeManagementService) - { - _profileService = profileService; - _syncService = syncService; - _dialogService = dialogService; - _storeManagementService = storeManagementService; - - _aiPackAddOn = CreateAddOnItem(WinoAddOnProductType.AI_PACK); - _unlimitedAccountsAddOn = CreateAddOnItem(WinoAddOnProductType.UNLIMITED_ACCOUNTS); - AddOns.Add(_aiPackAddOn); - AddOns.Add(_unlimitedAccountsAddOn); - } - - public override void OnNavigatedTo(NavigationMode mode, object parameters) - { - base.OnNavigatedTo(mode, parameters); - _ = InitializeAsync(); - } - - [RelayCommand] - private async Task RegisterAsync() - { - var account = await _dialogService.ShowWinoAccountRegistrationDialogAsync(); - if (account == null) - { - return; - } - - _dialogService.InfoBarMessage(Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_RegisterSuccessMessage, account.Email), - InfoBarMessageType.Success); - } - - [RelayCommand] - private async Task SignInAsync() - { - var account = await _dialogService.ShowWinoAccountLoginDialogAsync(); - if (account == null) - { - return; - } - - _dialogService.InfoBarMessage(Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_LoginSuccessMessage, account.Email), - InfoBarMessageType.Success); - } - - [RelayCommand] - private async Task SignOutAsync() - { - var account = await _profileService.GetActiveAccountAsync().ConfigureAwait(false); - if (account == null) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Warning, - Translator.WinoAccount_SignOut_NoAccountMessage, - InfoBarMessageType.Warning); - return; - } - - await _profileService.SignOutAsync().ConfigureAwait(false); - - _dialogService.InfoBarMessage(Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_SignOut_SuccessMessage, account.Email), - InfoBarMessageType.Success); - } - - [RelayCommand] - private async Task ChangePasswordAsync() - { - var account = await _profileService.GetActiveAccountAsync(); - if (account == null) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Warning, - Translator.WinoAccount_SignOut_NoAccountMessage, - InfoBarMessageType.Warning); - return; - } - - var shouldContinue = await _dialogService.ShowConfirmationDialogAsync( - string.Format(Translator.WinoAccount_ChangePassword_ConfirmationMessage, account.Email), - Translator.WinoAccount_ChangePassword_Title, - Translator.WinoAccount_ChangePassword_Action); - - if (!shouldContinue) - { - return; - } - - var response = await _profileService.ForgotPasswordAsync(account.Email); - if (!response.IsSuccess) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Error, - TranslateForgotPasswordError(response.ErrorCode), - InfoBarMessageType.Error); - return; - } - - _dialogService.InfoBarMessage(Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_ForgotPasswordDialog_SuccessMessage, account.Email), - InfoBarMessageType.Success); - } - - private static string TranslateForgotPasswordError(string? errorCode) - => errorCode switch - { - ApiErrorCodes.EmailNotRegistered => Translator.WinoAccount_Error_EmailNotRegistered, - ApiErrorCodes.ValidationFailed => Translator.WinoAccount_Error_ValidationFailed, - _ when string.IsNullOrWhiteSpace(errorCode) => Translator.GeneralTitle_Error, - _ => errorCode! - }; - - [RelayCommand(CanExecute = nameof(CanPurchaseAddOn))] - private async Task PurchaseAddOnAsync(WinoAddOnItemViewModel? addOn) - { - if (addOn == null) - { - return; - } - - await ExecuteUIThread(() => - { - IsCheckoutInProgress = true; - addOn.IsPurchaseInProgress = true; - }); - - try - { - var purchaseResult = await _storeManagementService.PurchaseAsync(addOn.ProductType); - - if (purchaseResult == StorePurchaseResult.NotPurchased) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Error, - Translator.WinoAccount_Management_PurchaseStartFailed, - InfoBarMessageType.Error); - return; - } - - var syncResult = await _profileService.SyncStoreEntitlementsAsync().ConfigureAwait(false); - if (!syncResult.IsSuccess && !string.Equals(syncResult.ErrorCode, "MissingAccessToken", StringComparison.Ordinal)) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Error, - TranslateStoreSyncError(syncResult.ErrorCode), - InfoBarMessageType.Error); - return; - } - - await HandleAddOnPurchasedAsync().ConfigureAwait(false); - } - catch (OperationCanceledException) - { - } - catch (Exception) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Error, - Translator.WinoAccount_Management_PurchaseStartFailed, - InfoBarMessageType.Error); - } - finally - { - await ExecuteUIThread(() => - { - IsCheckoutInProgress = false; - addOn.IsPurchaseInProgress = false; - }); - } - } - - private bool CanPurchaseAddOn(WinoAddOnItemViewModel? addOn) - => addOn != null && !addOn.IsPurchased && !addOn.IsLoading && !IsCheckoutInProgress; - - [RelayCommand] - private async Task ExportSettingsAsync() - { - try - { - var result = await _dialogService.ShowWinoAccountExportDialogAsync().ConfigureAwait(false); - if (result == null) - { - return; - } - - _dialogService.InfoBarMessage( - Translator.GeneralTitle_Info, - BuildExportSuccessMessage(result), - InfoBarMessageType.Success); - } - catch (Exception ex) - { - _dialogService.InfoBarMessage( - Translator.GeneralTitle_Error, - ex.Message, - InfoBarMessageType.Error); - } - } - - [RelayCommand] - private async Task ImportSettingsAsync() - { - await ExecuteUIThread(() => IsBusy = true); - - try - { - var result = await _syncService.ImportAsync(new WinoAccountSyncSelection()); - - if (!result.HasAnyRemoteData) - { - _dialogService.InfoBarMessage( - Translator.GeneralTitle_Info, - Translator.WinoAccount_Management_NoRemoteSettings, - InfoBarMessageType.Information); - return; - } - - var messageType = result.FailedPreferenceCount > 0 - ? InfoBarMessageType.Warning - : InfoBarMessageType.Success; - - _dialogService.InfoBarMessage( - result.FailedPreferenceCount > 0 ? Translator.GeneralTitle_Warning : Translator.GeneralTitle_Info, - BuildImportMessage(result), - messageType); - } - catch (Exception ex) - { - _dialogService.InfoBarMessage( - Translator.GeneralTitle_Error, - ex.Message, - InfoBarMessageType.Error); - } - finally - { - await ExecuteUIThread(() => IsBusy = false); - } - } - - protected override void RegisterRecipients() - { - base.RegisterRecipients(); - - Messenger.Register(this); - Messenger.Register(this); - Messenger.Register(this); - } - - protected override void UnregisterRecipients() - { - base.UnregisterRecipients(); - - Messenger.Unregister(this); - Messenger.Unregister(this); - Messenger.Unregister(this); - } - - public void Receive(WinoAccountProfileUpdatedMessage message) - => _ = LoadAsync(); - - public void Receive(WinoAccountProfileDeletedMessage message) - => _ = LoadAsync(); - - public void Receive(WinoAccountAddOnPurchasedMessage message) - => _ = HandleAddOnPurchasedAsync(); - - private async Task InitializeAsync() - { - await LoadAsync().ConfigureAwait(false); - } - - private async Task LoadAsync() - { - WinoAccount? cachedAccount = null; - - try - { - cachedAccount = await _profileService.GetActiveAccountAsync().ConfigureAwait(false); - - if (cachedAccount != null) - { - await ApplyAccountStateAsync(cachedAccount).ConfigureAwait(false); - } - - await ExecuteUIThread(() => IsBusy = true); - await ResetAddOnStatesAsync().ConfigureAwait(false); - var loadAiPackTask = LoadAiPackAddOnAsync(); - var loadUnlimitedAccountsTask = LoadUnlimitedAccountsAddOnAsync(); - - var resolvedAccount = cachedAccount; - - if (cachedAccount == null || IsAccessTokenExpired(cachedAccount)) - { - try - { - var account = await _profileService.GetAuthenticatedAccountAsync().ConfigureAwait(false); - if (account != null) - { - resolvedAccount = account; - - var refreshedProfileResult = await _profileService.RefreshProfileAsync().ConfigureAwait(false); - if (refreshedProfileResult.IsSuccess && refreshedProfileResult.Account != null) - { - resolvedAccount = refreshedProfileResult.Account; - } - } - } - catch (Exception) - { - resolvedAccount ??= cachedAccount; - } - } - - await ApplyAccountStateAsync(resolvedAccount).ConfigureAwait(false); - await Task.WhenAll(loadAiPackTask, loadUnlimitedAccountsTask).ConfigureAwait(false); - } - catch (Exception) - { - if (cachedAccount == null) - { - _dialogService.InfoBarMessage(Translator.GeneralTitle_Error, - Translator.WinoAccount_Management_LoadFailed, - InfoBarMessageType.Error); - await ResetStateAsync().ConfigureAwait(false); - } - } - finally - { - await ExecuteUIThread(() => IsBusy = false); - } - } - - private async Task ApplyAccountStateAsync(Wino.Core.Domain.Entities.Shared.WinoAccount? account) - { - await ExecuteUIThread(() => - { - IsSignedIn = account != null; - AccountEmail = account?.Email ?? string.Empty; - AccountStatusText = account == null - ? string.Empty - : string.Format(Translator.WinoAccount_Management_StatusLabel, account.AccountStatus); - }); - } - - private async Task HandleAddOnPurchasedAsync() - { - await LoadAsync().ConfigureAwait(false); - - _dialogService.InfoBarMessage(Translator.Info_PurchaseThankYouTitle, - Translator.Info_PurchaseThankYouMessage, - InfoBarMessageType.Success); - } - - private async Task ResetStateAsync() - { - await ExecuteUIThread(() => - { - IsSignedIn = false; - AccountEmail = string.Empty; - AccountStatusText = string.Empty; - IsCheckoutInProgress = false; - PurchaseAddOnCommand.NotifyCanExecuteChanged(); - }); - - await ResetAddOnStatesAsync().ConfigureAwait(false); - } - - private WinoAddOnItemViewModel CreateAddOnItem(WinoAddOnProductType productType) - { - return new WinoAddOnItemViewModel(productType) - { - PurchaseCommand = PurchaseAddOnCommand, - UsageLimit = 1 - }; - } - - private async Task ResetAddOnStatesAsync() - { - await ExecuteUIThread(() => - { - ResetAddOnItem(_aiPackAddOn); - ResetAddOnItem(_unlimitedAccountsAddOn); - PurchaseAddOnCommand.NotifyCanExecuteChanged(); - }); - } - - private static void ResetAddOnItem(WinoAddOnItemViewModel addOn) - { - addOn.IsLoading = true; - addOn.IsPurchased = false; - addOn.IsPurchaseInProgress = false; - addOn.HasUsageData = false; - addOn.ErrorText = string.Empty; - addOn.UsageCount = 0; - addOn.UsageLimit = 1; - addOn.UsagePercentage = 0; - addOn.RenewalText = string.Empty; - addOn.UsageResetText = string.Empty; - } - - private static string TranslateStoreSyncError(string? errorCode) - => errorCode switch - { - _ => Translator.WinoAccount_Management_StoreSyncFailed - }; - - private static string BuildExportSuccessMessage(WinoAccountSyncExportResult result) - { - var parts = new Collection(); - - if (result.IncludedPreferences) - { - parts.Add(Translator.WinoAccount_Management_ExportPreferencesSucceeded); - } - - if (result.IncludedAccounts) - { - parts.Add(string.Format(Translator.WinoAccount_Management_ExportAccountsSucceeded, result.ExportedMailboxCount)); - } - - if (parts.Count == 0) - { - parts.Add(Translator.WinoAccount_Management_ExportSucceeded); - } - - return string.Join(" ", parts); - } - - private static string BuildImportMessage(WinoAccountSyncImportResult result) - { - var parts = new Collection(); - - if (result.HadRemotePreferences) - { - parts.Add(result.FailedPreferenceCount > 0 - ? string.Format(Translator.WinoAccount_Management_ImportPartial, result.AppliedPreferenceCount, result.FailedPreferenceCount) - : string.Format(Translator.WinoAccount_Management_ImportPreferencesSucceeded, result.AppliedPreferenceCount)); - } - - if (result.ImportedMailboxCount > 0) - { - parts.Add(string.Format(Translator.WinoAccount_Management_ImportAccountsSucceeded, result.ImportedMailboxCount)); - } - - if (result.SkippedDuplicateMailboxCount > 0) - { - parts.Add(string.Format(Translator.WinoAccount_Management_ImportDuplicateAccountsSkipped, result.SkippedDuplicateMailboxCount)); - } - - if (parts.Count == 0) - { - parts.Add(Translator.WinoAccount_Management_ImportEmpty); - } - - if (result.ImportedMailboxCount > 0) - { - parts.Add(Translator.WinoAccount_Management_ImportReloginReminder); - } - - return string.Join(" ", parts); - } - - private static bool IsAccessTokenExpired(WinoAccount account) - => string.IsNullOrWhiteSpace(account.AccessToken) || account.AccessTokenExpiresAtUtc <= DateTime.UtcNow; - - private async Task LoadUnlimitedAccountsAddOnAsync() - { - try - { - var hasUnlimitedAccounts = await _storeManagementService.HasProductAsync(WinoAddOnProductType.UNLIMITED_ACCOUNTS).ConfigureAwait(false); - await ExecuteUIThread(() => - { - _unlimitedAccountsAddOn.IsPurchased = hasUnlimitedAccounts; - _unlimitedAccountsAddOn.ErrorText = string.Empty; - }); - } - catch (Exception) - { - await ExecuteUIThread(() => - { - _unlimitedAccountsAddOn.ErrorText = Translator.WinoAccount_Management_AddOnLoadFailed; - }); - } - finally - { - await ExecuteUIThread(() => - { - _unlimitedAccountsAddOn.IsLoading = false; - PurchaseAddOnCommand.NotifyCanExecuteChanged(); - }); - } - } - - private async Task LoadAiPackAddOnAsync() - { - try - { - var hasAiPack = await _storeManagementService.HasProductAsync(WinoAddOnProductType.AI_PACK).ConfigureAwait(false); - - await ExecuteUIThread(() => - { - _aiPackAddOn.IsPurchased = hasAiPack; - _aiPackAddOn.ErrorText = string.Empty; - }); - - if (!hasAiPack) - { - return; - } - - var aiStatusResponse = await _profileService.GetAiStatusAsync().ConfigureAwait(false); - if (!aiStatusResponse.IsSuccess || aiStatusResponse.Result == null) - { - await ExecuteUIThread(() => - { - _aiPackAddOn.HasUsageData = false; - _aiPackAddOn.ErrorText = Translator.WinoAccount_Management_AiPackUsageLoadFailed; - }); - return; - } - - var aiStatus = aiStatusResponse.Result; - if (IsExpiredAiEntitlement(aiStatus.EntitlementStatus)) - { - await ExecuteUIThread(() => - { - _aiPackAddOn.IsPurchased = false; - _aiPackAddOn.HasUsageData = false; - _aiPackAddOn.ErrorText = string.Empty; - _aiPackAddOn.RenewalText = string.Empty; - _aiPackAddOn.UsageResetText = string.Empty; - }); - return; - } - - if (aiStatus.MonthlyLimit is not int usageLimit || usageLimit <= 0 || aiStatus.Used is not int usageCount) - { - await ExecuteUIThread(() => - { - _aiPackAddOn.HasUsageData = false; - _aiPackAddOn.ErrorText = Translator.WinoAccount_Management_AiPackUsageLoadFailed; - }); - return; - } - - await ExecuteUIThread(() => - { - _aiPackAddOn.HasUsageData = true; - _aiPackAddOn.ErrorText = string.Empty; - _aiPackAddOn.UsageCount = usageCount; - _aiPackAddOn.UsageLimit = usageLimit; - _aiPackAddOn.UsagePercentage = usageLimit > 0 ? (double)usageCount / usageLimit * 100 : 0; - _aiPackAddOn.RenewalText = aiStatus.CurrentPeriodEndUtc is DateTimeOffset renewalDateUtc - ? string.Format(Translator.WinoAccount_Management_AiPackRenews, renewalDateUtc.LocalDateTime) - : string.Empty; - _aiPackAddOn.UsageResetText = aiStatus.CurrentPeriodEndUtc is DateTimeOffset resetDateUtc - ? string.Format(Translator.WinoAccount_Management_AiPackResets, resetDateUtc.LocalDateTime) - : string.Empty; - }); - } - catch (Exception) - { - await ExecuteUIThread(() => - { - _aiPackAddOn.HasUsageData = false; - _aiPackAddOn.ErrorText = Translator.WinoAccount_Management_AddOnLoadFailed; - }); - } - finally - { - await ExecuteUIThread(() => - { - _aiPackAddOn.IsLoading = false; - PurchaseAddOnCommand.NotifyCanExecuteChanged(); - }); - } - } - - private static bool IsExpiredAiEntitlement(string? entitlementStatus) - => string.Equals(entitlementStatus, "Expired", StringComparison.OrdinalIgnoreCase); -} diff --git a/Wino.Mail.ViewModels/WelcomePageV2ViewModel.cs b/Wino.Mail.ViewModels/WelcomePageV2ViewModel.cs index a3021e8d..12c872fc 100644 --- a/Wino.Mail.ViewModels/WelcomePageV2ViewModel.cs +++ b/Wino.Mail.ViewModels/WelcomePageV2ViewModel.cs @@ -73,40 +73,6 @@ public partial class WelcomePageV2ViewModel : MailBaseViewModel ProviderSelectionNavigationContext.CreateForWizard())); } - [RelayCommand(CanExecute = nameof(CanOpenWelcomeActions))] - private async Task ImportFromWinoAccountAsync() - { - await ExecuteUIThread(() => ImportStatusMessage = string.Empty); - - try - { - var account = await _dialogService.ShowWinoAccountLoginDialogAsync().ConfigureAwait(false); - if (account == null) - { - return; - } - - await ExecuteUIThread(() => IsImportInProgress = true); - - var result = await _syncService.ImportAsync(new WinoAccountSyncSelection()).ConfigureAwait(false); - if (result.ImportedMailboxCount > 0) - { - ReportUIChange(new WelcomeImportCompletedMessage(result.ImportedMailboxCount)); - return; - } - - await ExecuteUIThread(() => ImportStatusMessage = BuildInlineImportMessage(result)); - } - catch (Exception ex) - { - await _dialogService.ShowMessageAsync(ex.Message, Translator.GeneralTitle_Error, WinoCustomMessageDialogIcon.Error); - } - finally - { - await ExecuteUIThread(() => IsImportInProgress = false); - } - } - [RelayCommand(CanExecute = nameof(CanOpenWelcomeActions))] private async Task ImportFromJsonAsync() { diff --git a/Wino.Mail.WinUI/App.xaml.cs b/Wino.Mail.WinUI/App.xaml.cs index 82ee2f5f..918469ca 100644 --- a/Wino.Mail.WinUI/App.xaml.cs +++ b/Wino.Mail.WinUI/App.xaml.cs @@ -413,7 +413,6 @@ public partial class App : WinoApplication, services.AddTransient(typeof(MergedAccountDetailsPageViewModel)); services.AddTransient(typeof(AppPreferencesPageViewModel)); services.AddTransient(typeof(StoragePageViewModel)); - services.AddTransient(typeof(WinoAccountManagementPageViewModel)); services.AddTransient(typeof(AliasManagementPageViewModel)); services.AddTransient(typeof(MailCategoryManagementPageViewModel)); services.AddTransient(typeof(ContactsPageViewModel)); @@ -1656,15 +1655,9 @@ public partial class App : WinoApplication, _autoSynchronizationLoopCts = null; } - private async Task LoadInitialWinoAccountAsync() + private Task LoadInitialWinoAccountAsync() { - var winoAccountProfileService = Services.GetRequiredService(); - var winoAccount = await winoAccountProfileService.GetActiveAccountAsync(); - - if (winoAccount != null) - { - WeakReferenceMessenger.Default.Send(new WinoAccountProfileUpdatedMessage(winoAccount)); - } + return Task.CompletedTask; } private async Task RunAutoSynchronizationLoopAsync(TimeSpan interval, CancellationToken cancellationToken) diff --git a/Wino.Mail.WinUI/Controls/AiActionsPanel.xaml b/Wino.Mail.WinUI/Controls/AiActionsPanel.xaml deleted file mode 100644 index dafe36a9..00000000 --- a/Wino.Mail.WinUI/Controls/AiActionsPanel.xaml +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Wino.Mail.WinUI/ShellWindow.xaml.cs b/Wino.Mail.WinUI/ShellWindow.xaml.cs index c11f9344..9506c733 100644 --- a/Wino.Mail.WinUI/ShellWindow.xaml.cs +++ b/Wino.Mail.WinUI/ShellWindow.xaml.cs @@ -34,16 +34,12 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, IRecipient, IRecipient, IRecipient, - IRecipient, - IRecipient, - IRecipient + IRecipient { private bool _allowClose; public IStatePersistanceService StatePersistanceService { get; } = WinoApplication.Current.Services.GetService() ?? throw new Exception("StatePersistanceService not registered in DI container."); public IPreferencesService PreferencesService { get; } = WinoApplication.Current.Services.GetService() ?? throw new Exception("PreferencesService not registered in DI container."); public INavigationService NavigationService { get; } = WinoApplication.Current.Services.GetService() ?? throw new Exception("NavigationService not registered in DI container."); - private IMailDialogService MailDialogService { get; } = WinoApplication.Current.Services.GetRequiredService(); - private IWinoAccountProfileService WinoAccountProfileService { get; } = WinoApplication.Current.Services.GetRequiredService(); public ObservableCollection SyncActionItems { get; } = new(); private bool _calendarReminderServerStartAttempted; @@ -210,15 +206,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, }); } - public void Receive(WinoAccountProfileUpdatedMessage message) - { - DispatcherQueue.TryEnqueue(() => UpdateWinoAccountState(message.Account)); - } - - public void Receive(WinoAccountProfileDeletedMessage message) - { - DispatcherQueue.TryEnqueue(() => UpdateWinoAccountState(null)); - } private void UpdateSyncStatusVisibility() { @@ -426,8 +413,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this); WeakReferenceMessenger.Default.Register(this); - WeakReferenceMessenger.Default.Register(this); - WeakReferenceMessenger.Default.Register(this); } private void UnregisterRecipients() @@ -437,8 +422,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, WeakReferenceMessenger.Default.Unregister(this); WeakReferenceMessenger.Default.Unregister(this); WeakReferenceMessenger.Default.Unregister(this); - WeakReferenceMessenger.Default.Unregister(this); - WeakReferenceMessenger.Default.Unregister(this); } private void ShowInfoBarMessage(InfoBarMessageRequested message) @@ -465,29 +448,6 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, }); } - private void UpdateWinoAccountState(WinoAccount? account) - { - var isSignedIn = account != null; - - WinoAccountSignedOutView.Visibility = isSignedIn ? Visibility.Collapsed : Visibility.Visible; - WinoAccountSignedInView.Visibility = isSignedIn ? Visibility.Visible : Visibility.Collapsed; - - WinoAccountButtonPicture.Visibility = isSignedIn ? Visibility.Visible : Visibility.Collapsed; - WinoAccountSignedOutIcon.Visibility = isSignedIn ? Visibility.Collapsed : Visibility.Visible; - - var initials = GetInitials(account?.Email); - - WinoAccountButtonPicture.Initials = initials; - WinoAccountFlyoutPicture.Initials = initials; - WinoAccountButtonPicture.DisplayName = account?.Email ?? Translator.WinoAccount_Titlebar_SignedOutTitle; - WinoAccountFlyoutPicture.DisplayName = account?.Email ?? Translator.WinoAccount_Titlebar_SignedOutTitle; - - WinoAccountFlyoutEmailText.Text = account?.Email ?? string.Empty; - WinoAccountFlyoutStatusText.Text = account == null - ? string.Empty - : string.Format(Translator.WinoAccount_Titlebar_SignedInStatus, account.AccountStatus); - } - private static string GetInitials(string? email) { if (string.IsNullOrWhiteSpace(email)) @@ -510,50 +470,5 @@ public sealed partial class ShellWindow : WindowEx, IWinoShellWindow, return string.Concat(segments.Select(segment => char.ToUpperInvariant(segment[0]))); } - private async void RegisterWinoAccountClicked(object sender, RoutedEventArgs e) - { - WinoAccountFlyout.Hide(); - var account = await MailDialogService.ShowWinoAccountRegistrationDialogAsync(); - if (account != null) - { - ShowInfoBarMessage(new InfoBarMessageRequested( - InfoBarMessageType.Success, - Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_RegisterSuccessMessage, account.Email))); - } - } - - private async void LoginWinoAccountClicked(object sender, RoutedEventArgs e) - { - WinoAccountFlyout.Hide(); - var account = await MailDialogService.ShowWinoAccountLoginDialogAsync(); - if (account != null) - { - ShowInfoBarMessage(new InfoBarMessageRequested( - InfoBarMessageType.Success, - Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_LoginSuccessMessage, account.Email))); - } - } - - private async void SignOutWinoAccountClicked(object sender, RoutedEventArgs e) - { - var activeAccount = await WinoAccountProfileService.GetActiveAccountAsync(); - if (activeAccount == null) - { - ShowInfoBarMessage(new InfoBarMessageRequested( - InfoBarMessageType.Warning, - Translator.GeneralTitle_Info, - Translator.WinoAccount_SignOut_NoAccountMessage)); - return; - } - - await WinoAccountProfileService.SignOutAsync(); - - ShowInfoBarMessage(new InfoBarMessageRequested( - InfoBarMessageType.Success, - Translator.GeneralTitle_Info, - string.Format(Translator.WinoAccount_SignOut_SuccessMessage, activeAccount.Email))); - } } diff --git a/Wino.Mail.WinUI/Views/Abstract/WinoAccountManagementPageAbstract.cs b/Wino.Mail.WinUI/Views/Abstract/WinoAccountManagementPageAbstract.cs deleted file mode 100644 index ee436e61..00000000 --- a/Wino.Mail.WinUI/Views/Abstract/WinoAccountManagementPageAbstract.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Wino.Core.ViewModels; - -namespace Wino.Views.Abstract; - -public abstract class WinoAccountManagementPageAbstract : SettingsPageBase -{ -} diff --git a/Wino.Mail.WinUI/Views/Mail/ComposePage.xaml b/Wino.Mail.WinUI/Views/Mail/ComposePage.xaml index 011fa126..2429d5bf 100644 --- a/Wino.Mail.WinUI/Views/Mail/ComposePage.xaml +++ b/Wino.Mail.WinUI/Views/Mail/ComposePage.xaml @@ -160,18 +160,6 @@ Visibility="{x:Bind ViewModel.IsDraftBusy, Mode=OneWay}"> - - - - - - WebViewEditor.GetUnderlyingWebView(); - public Visibility GetAiActionsToggleVisibility(bool isHidden) => isHidden ? Visibility.Collapsed : Visibility.Visible; public Visibility GetPopOutButtonVisibility() => SupportsPopOut ? Visibility.Visible : Visibility.Collapsed; - public Visibility GetAiActionsPanelVisibility(bool? isChecked, bool isHidden) - => !isHidden && isChecked == true ? Visibility.Visible : Visibility.Collapsed; - private readonly List _disposables = []; public ComposePage() @@ -343,11 +339,6 @@ public sealed partial class ComposePage : ComposePageAbstract, HostActionRequested?.Invoke(this, new PopoutHostActionRequestedEventArgs(PopoutHostActionKind.CloseHostedInstance)); } - private async void ComposeAiActionsToggleButton_Checked(object sender, RoutedEventArgs e) - { - await ComposeAiActionsPanel.RefreshAvailabilityAsync(); - } - private async void TokenItemAdding(TokenizingTextBox sender, TokenItemAddingEventArgs args) { var deferral = args.GetDeferral(); @@ -504,7 +495,6 @@ public sealed partial class ComposePage : ComposePageAbstract, base.OnNavigatingFrom(e); FocusManager.GotFocus -= GlobalFocusManagerGotFocus; - ComposeAiActionsPanel.CancelPendingOperation(); await ViewModel.UpdateMimeChangesAsync(); ViewModel.SaveHTMLasPDFFunc = null; ViewModel.RenderHtmlBodyAsyncFunc = null; diff --git a/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml b/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml index 4f6cdccb..7d9233f1 100644 --- a/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml +++ b/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml @@ -269,7 +269,7 @@ Grid.Row="1" HorizontalContentAlignment="Stretch" DefaultLabelPosition="Right" - IsAIActionsPaneToggleVisible="{x:Bind GetAiActionsToggleVisible(ViewModel.PreferencesService.IsAiActionsPanelHidden), Mode=OneWay}" + IsAIActionsPaneToggleVisible="False" IsEditorThemeDark="{x:Bind ViewModel.IsDarkWebviewRenderer, Mode=TwoWay}" IsEditorThemeToggleVisible="True" IsPopOutButtonVisible="{x:Bind SupportsPopOut, Mode=OneWay}" @@ -411,13 +411,6 @@ - diff --git a/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml.cs b/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml.cs index 31b7fcdb..bea07abe 100644 --- a/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml.cs +++ b/Wino.Mail.WinUI/Views/Mail/MailRenderingPage.xaml.cs @@ -49,9 +49,6 @@ public sealed partial class MailRenderingPage : MailRenderingPageAbstract, public event EventHandler? HostActionRequested; public WebView2 GetWebView() => Chromium; - public bool GetAiActionsToggleVisible(bool isHidden) => !isHidden; - public Visibility GetAiActionsPanelVisibility(bool isEnabled, bool isHidden) - => !isHidden && isEnabled ? Visibility.Visible : Visibility.Collapsed; public MailRenderingPage() { @@ -179,7 +176,6 @@ public sealed partial class MailRenderingPage : MailRenderingPageAbstract, RendererCommandBar.AIActionsEnabledChanged -= RendererCommandBar_AIActionsEnabledChanged; RendererCommandBar.PopOutClicked -= RendererCommandBar_PopOutClicked; RendererCommandBar.IsAIActionsEnabled = false; - ReaderAiActionsPanel.CancelPendingOperation(); DisposeWebView2(); } @@ -206,7 +202,6 @@ public sealed partial class MailRenderingPage : MailRenderingPageAbstract, { if (isEnabled) { - await ReaderAiActionsPanel.RefreshAvailabilityAsync(); } } diff --git a/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml b/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml index aae7fdd3..5d3201e8 100644 --- a/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml +++ b/Wino.Mail.WinUI/Views/Settings/AppPreferencesPage.xaml @@ -137,19 +137,6 @@ - - - - - - - - - diff --git a/Wino.Mail.WinUI/Views/Settings/WinoAccountManagementPage.xaml b/Wino.Mail.WinUI/Views/Settings/WinoAccountManagementPage.xaml deleted file mode 100644 index daeb3d4c..00000000 --- a/Wino.Mail.WinUI/Views/Settings/WinoAccountManagementPage.xaml +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - - - - - - - - - - - - - - -