Files
Wino-Mail/Wino.Mail.ViewModels/AccountManagementViewModel.cs

431 lines
20 KiB
C#
Raw Normal View History

2024-04-18 01:44:37 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
2024-04-18 01:44:37 +02:00
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using Serilog;
using Wino.Core.Domain;
using Wino.Core.Domain.Entities.Mail;
using Wino.Core.Domain.Entities.Shared;
2024-04-18 01:44:37 +02:00
using Wino.Core.Domain.Enums;
using Wino.Core.Domain.Exceptions;
using Wino.Core.Domain.Interfaces;
using Wino.Core.Domain.Models.Authentication;
using Wino.Core.Domain.Models.Connectivity;
2024-04-18 01:44:37 +02:00
using Wino.Core.Domain.Models.Navigation;
using Wino.Core.Domain.Models.Synchronization;
using Wino.Core.ViewModels;
using Wino.Core.ViewModels.Data;
2024-04-18 01:44:37 +02:00
using Wino.Mail.ViewModels.Data;
Full trust Wino Server implementation. (#295) * Separation of messages. Introducing Wino.Messages library. * Wino.Server and Wino.Packaging projects. Enabling full trust for UWP and app service connection manager basics. * Remove debug code. * Enable generating assembly info to deal with unsupported os platform warnings. * Fix server-client connection. * UIMessage communication. Single instancing for server and re-connection mechanism on suspension. * Removed IWinoSynchronizerFactory from UWP project. * Removal of background task service from core. * Delegating changes to UI and triggering new background synchronization. * Fix build error. * Moved core lib messages to Messaging project. * Better client-server communication. Handling of requests in the server. New synchronizer factory in the server. * WAM broker and MSAL token caching for OutlookAuthenticator. Handling account creation for Outlook. * WinoServerResponse basics. * Delegating protocol activation for Gmail authenticator. * Adding margin to searchbox to match action bar width. * Move libraries into lib folder. * Storing base64 encoded mime on draft creation instead of MimeMessage object. Fixes serialization/deserialization issue with S.T.Json * Scrollbar adjustments * WınoExpander for thread expander layout ıssue. * Handling synchronizer state changes. * Double init on background activation. * FIxing packaging issues and new Wino Mail launcher protocol for activation from full thrust process. * Remove debug deserialization. * Remove debug code. * Making sure the server connection is established when the app is launched. * Thrust -> Trust string replacement... * Rename package to Wino Mail * Enable translated values in the server. * Fixed an issue where toast activation can't find the clicked mail after the folder is initialized. * Revert debug code. * Change server background sync to every 3 minute and Inbox only synchronization. * Revert google auth changes. * App preferences page. * Changing tray icon visibility on preference change. * Start the server with invisible tray icon if set to invisible. * Reconnect button on the title bar. * Handling of toast actions. * Enable x86 build for server during packaging. * Get rid of old background tasks and v180 migration. * Terminate client when Exit clicked in server. * Introducing SynchronizationSource to prevent notifying UI after server tick synchronization. * Remove confirmAppClose restricted capability and unused debug code in manifest. * Closing the reconnect info popup when reconnect is clicked. * Custom RetryHandler for OutlookSynchronizer and separating client/server logs. * Running server on Windows startup. * Fix startup exe. * Fix for expander list view item paddings. * Force full sync on app launch instead of Inbox. * Fix draft creation. * Fix an issue with custom folder sync logic. * Reporting back account sync progress from server. * Fix sending drafts and missing notifications for imap. * Changing imap folder sync requirements. * Retain file count is set to 3. * Disabled swipe gestures temporarily due to native crash with SwipeControl * Save all attachments implementation. * Localization for save all attachments button. * Fix logging dates for logs. * Fixing ARM64 build. * Add ARM64 build config to packaging project. * Comment out OutOfProcPDB for ARM64. * Hnadling GONE response for Outlook folder synchronization.
2024-08-05 00:36:26 +02:00
using Wino.Messaging.Client.Navigation;
using Wino.Messaging.Server;
using Wino.Messaging.UI;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
namespace Wino.Mail.ViewModels;
public partial class AccountManagementViewModel : AccountManagementPageViewModelBase
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
private readonly ISpecialImapProviderConfigResolver _specialImapProviderConfigResolver;
private readonly IImapTestService _imapTestService;
private readonly IWinoLogger _winoLogger;
2025-02-16 11:54:23 +01:00
public IMailDialogService MailDialogService { get; }
public AccountManagementViewModel(IMailDialogService dialogService,
IWinoServerConnectionManager winoServerConnectionManager,
INavigationService navigationService,
IAccountService accountService,
ISpecialImapProviderConfigResolver specialImapProviderConfigResolver,
IProviderService providerService,
IImapTestService imapTestService,
IStoreManagementService storeManagementService,
IWinoLogger winoLogger,
2025-02-16 11:54:23 +01:00
IAuthenticationProvider authenticationProvider,
IPreferencesService preferencesService) : base(dialogService, winoServerConnectionManager, navigationService, accountService, providerService, storeManagementService, authenticationProvider, preferencesService)
2025-02-16 11:35:43 +01:00
{
2025-02-16 11:54:23 +01:00
MailDialogService = dialogService;
_specialImapProviderConfigResolver = specialImapProviderConfigResolver;
_imapTestService = imapTestService;
_winoLogger = winoLogger;
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
[RelayCommand]
private async Task CreateMergedAccountAsync()
{
var linkName = await DialogService.ShowTextInputDialogAsync(string.Empty, Translator.DialogMessage_CreateLinkedAccountTitle, Translator.DialogMessage_CreateLinkedAccountMessage, Translator.Buttons_Create);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (string.IsNullOrEmpty(linkName)) return;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Create arbitary empty merged inbox with an empty Guid and go to edit page.
var mergedInbox = new MergedInbox()
{
Id = Guid.Empty,
Name = linkName
};
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var mergedAccountProviderDetailViewModel = new MergedAccountProviderDetailViewModel(mergedInbox, new List<AccountProviderDetailViewModel>());
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
Messenger.Send(new BreadcrumbNavigationRequested(mergedAccountProviderDetailViewModel.MergedInbox.Name,
WinoPage.MergedAccountDetailsPage,
mergedAccountProviderDetailViewModel));
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
[RelayCommand]
private async Task AddNewAccountAsync()
{
if (IsAccountCreationBlocked)
{
2025-02-16 11:54:23 +01:00
var isPurchaseClicked = await DialogService.ShowConfirmationDialogAsync(Translator.DialogMessage_AccountLimitMessage, Translator.DialogMessage_AccountLimitTitle, Translator.Buttons_Purchase);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
if (!isPurchaseClicked) return;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await PurchaseUnlimitedAccountAsync();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
return;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
MailAccount createdAccount = null;
IAccountCreationDialog creationDialog = null;
2025-02-16 11:54:23 +01:00
try
{
var providers = ProviderService.GetAvailableProviders();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Select provider.
var accountCreationDialogResult = await MailDialogService.ShowAccountProviderSelectionDialogAsync(providers);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var accountCreationCancellationTokenSource = new CancellationTokenSource();
2025-02-16 11:54:23 +01:00
if (accountCreationDialogResult != null)
{
creationDialog = MailDialogService.GetAccountCreationDialog(accountCreationDialogResult);
2025-02-16 11:54:23 +01:00
CustomServerInformation customServerInformation = null;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
createdAccount = new MailAccount()
{
ProviderType = accountCreationDialogResult.ProviderType,
Name = accountCreationDialogResult.AccountName,
SpecialImapProvider = accountCreationDialogResult.SpecialImapProviderDetails?.SpecialImapProvider ?? SpecialImapProvider.None,
Id = Guid.NewGuid(),
AccountColorHex = accountCreationDialogResult.AccountColorHex
2025-02-16 11:54:23 +01:00
};
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await creationDialog.ShowDialogAsync(accountCreationCancellationTokenSource);
await Task.Delay(500);
2025-02-16 11:54:23 +01:00
creationDialog.State = AccountCreationDialogState.SigningIn;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
string tokenInformation = string.Empty;
2025-02-16 11:54:23 +01:00
// Custom server implementation requires more async waiting.
if (creationDialog is IImapAccountCreationDialog customServerDialog)
{
// Pass along the account properties and perform initial navigation on the imap frame.
customServerDialog.StartImapConnectionSetup(createdAccount);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
customServerInformation = await customServerDialog.GetCustomServerInformationAsync()
?? throw new AccountSetupCanceledException();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// At this point connection is successful.
// Save the server setup information and later on we'll fetch folders.
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
customServerInformation.AccountId = createdAccount.Id;
createdAccount.Address = customServerInformation.Address;
createdAccount.ServerInformation = customServerInformation;
createdAccount.SenderName = customServerInformation.DisplayName;
}
else
{
// Hanle special imap providers like iCloud and Yahoo.
if (accountCreationDialogResult.SpecialImapProviderDetails != null)
{
// Special imap provider testing dialog. This is only available for iCloud and Yahoo.
customServerInformation = _specialImapProviderConfigResolver.GetServerInformation(createdAccount, accountCreationDialogResult);
customServerInformation.Id = Guid.NewGuid();
2024-04-18 01:44:37 +02:00
customServerInformation.AccountId = createdAccount.Id;
2025-02-16 11:54:23 +01:00
createdAccount.SenderName = accountCreationDialogResult.SpecialImapProviderDetails.SenderName;
2024-04-18 01:44:37 +02:00
createdAccount.Address = customServerInformation.Address;
2025-02-16 11:54:23 +01:00
// Let server validate the imap/smtp connection.
var testResultResponse = await WinoServerConnectionManager.GetResponseAsync<ImapConnectivityTestResults, ImapConnectivityTestRequested>(new ImapConnectivityTestRequested(customServerInformation, true));
if (!testResultResponse.IsSuccess)
{
throw new Exception($"{Translator.IMAPSetupDialog_ConnectionFailedTitle}\n{testResultResponse.Message}");
}
else if (!testResultResponse.Data.IsSuccess)
{
// Server connectivity might succeed, but result might be failed.
throw new ImapClientPoolException(testResultResponse.Data.FailedReason, customServerInformation, testResultResponse.Data.FailureProtocolLog);
}
2024-04-18 01:44:37 +02:00
}
else
{
2025-02-16 11:54:23 +01:00
// OAuth authentication is handled here.
// Server authenticates, returns the token info here.
2025-02-16 11:54:23 +01:00
var tokenInformationResponse = await WinoServerConnectionManager
.GetResponseAsync<TokenInformationEx, AuthorizationRequested>(new AuthorizationRequested(accountCreationDialogResult.ProviderType,
createdAccount,
createdAccount.ProviderType == MailProviderType.Gmail), accountCreationCancellationTokenSource.Token);
2025-02-16 11:54:23 +01:00
if (creationDialog.State == AccountCreationDialogState.Canceled)
throw new AccountSetupCanceledException();
2024-08-17 19:54:52 +02:00
2025-02-16 11:54:23 +01:00
if (!tokenInformationResponse.IsSuccess)
throw new Exception(tokenInformationResponse.Message);
2025-02-16 11:54:23 +01:00
createdAccount.Address = tokenInformationResponse.Data.AccountAddress;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
tokenInformationResponse.ThrowIfFailed();
}
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Address is still doesn't have a value for API synchronizers.
// It'll be synchronized with profile information.
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
await AccountService.CreateAccountAsync(createdAccount, customServerInformation);
2025-02-16 11:54:23 +01:00
// Local account has been created.
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Sync profile information if supported.
if (createdAccount.IsProfileInfoSyncSupported)
{
// Start profile information synchronization.
// It's only available for Outlook and Gmail synchronizers.
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var profileSyncOptions = new MailSynchronizationOptions()
2024-08-17 19:54:52 +02:00
{
AccountId = createdAccount.Id,
2025-02-16 11:54:23 +01:00
Type = MailSynchronizationType.UpdateProfile
};
2025-02-16 11:54:23 +01:00
var profileSynchronizationResponse = await WinoServerConnectionManager.GetResponseAsync<MailSynchronizationResult, NewMailSynchronizationRequested>(new NewMailSynchronizationRequested(profileSyncOptions, SynchronizationSource.Client));
var profileSynchronizationResult = profileSynchronizationResponse.Data;
2024-08-17 19:54:52 +02:00
2025-02-16 11:54:23 +01:00
if (profileSynchronizationResult.CompletedState != SynchronizationCompletedState.Success)
throw new Exception(Translator.Exception_FailedToSynchronizeProfileInformation);
2024-08-17 19:54:52 +02:00
2025-02-16 11:54:23 +01:00
createdAccount.SenderName = profileSynchronizationResult.ProfileInformation.SenderName;
createdAccount.Base64ProfilePictureData = profileSynchronizationResult.ProfileInformation.Base64ProfilePictureData;
2025-02-16 11:54:23 +01:00
if (!string.IsNullOrEmpty(profileSynchronizationResult.ProfileInformation.AccountAddress))
{
2025-02-16 11:54:23 +01:00
createdAccount.Address = profileSynchronizationResult.ProfileInformation.AccountAddress;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await AccountService.UpdateProfileInformationAsync(createdAccount.Id, profileSynchronizationResult.ProfileInformation);
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
if (creationDialog is IImapAccountCreationDialog customServerAccountCreationDialog)
customServerAccountCreationDialog.ShowPreparingFolders();
else
creationDialog.State = AccountCreationDialogState.PreparingFolders;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Start synchronizing folders.
var folderSyncOptions = new MailSynchronizationOptions()
{
AccountId = createdAccount.Id,
Type = MailSynchronizationType.FoldersOnly
};
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var folderSynchronizationResponse = await WinoServerConnectionManager.GetResponseAsync<MailSynchronizationResult, NewMailSynchronizationRequested>(new NewMailSynchronizationRequested(folderSyncOptions, SynchronizationSource.Client));
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
var folderSynchronizationResult = folderSynchronizationResponse.Data;
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
if (folderSynchronizationResult == null || folderSynchronizationResult.CompletedState != SynchronizationCompletedState.Success)
throw new Exception($"{Translator.Exception_FailedToSynchronizeFolders}\n{folderSynchronizationResponse.Message}");
2025-02-16 11:54:23 +01:00
// Sync aliases if supported.
if (createdAccount.IsAliasSyncSupported)
{
// Try to synchronize aliases for the account.
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
var aliasSyncOptions = new MailSynchronizationOptions()
{
AccountId = createdAccount.Id,
Type = MailSynchronizationType.Alias
};
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
var aliasSyncResponse = await WinoServerConnectionManager.GetResponseAsync<MailSynchronizationResult, NewMailSynchronizationRequested>(new NewMailSynchronizationRequested(aliasSyncOptions, SynchronizationSource.Client));
var aliasSynchronizationResult = folderSynchronizationResponse.Data;
if (aliasSynchronizationResult.CompletedState != SynchronizationCompletedState.Success)
throw new Exception(Translator.Exception_FailedToSynchronizeAliases);
}
else
{
2025-02-16 11:54:23 +01:00
// Create root primary alias for the account.
// This is only available for accounts that do not support alias synchronization.
await AccountService.CreateRootAliasAsync(createdAccount.Id, createdAccount.Address);
}
2025-02-16 11:54:23 +01:00
// Send changes to listeners.
ReportUIChange(new AccountCreatedMessage(createdAccount));
// Notify success.
DialogService.InfoBarMessage(Translator.Info_AccountCreatedTitle, string.Format(Translator.Info_AccountCreatedMessage, createdAccount.Address), InfoBarMessageType.Success);
}
2025-02-16 11:54:23 +01:00
}
catch (Exception ex) when (ex.Message.Contains(nameof(GmailServiceDisabledException)))
{
// For Google Workspace accounts, Gmail API might be disabled by the admin.
// Wino can't continue synchronization in this case.
// We must notify the user about this and prevent account creation.
DialogService.InfoBarMessage(Translator.GmailServiceDisabled_Title, Translator.GmailServiceDisabled_Message, InfoBarMessageType.Error);
if (createdAccount != null)
{
await AccountService.DeleteAccountAsync(createdAccount);
}
}
2025-02-16 11:54:23 +01:00
catch (AccountSetupCanceledException)
{
// Ignore
}
catch (Exception ex) when (ex.Message.Contains(nameof(AccountSetupCanceledException)))
{
// Ignore
}
catch (ImapClientPoolException testClientPoolException) when (testClientPoolException.CustomServerInformation != null)
{
var properties = testClientPoolException.CustomServerInformation.GetConnectionProperties();
properties.Add("ProtocolLog", testClientPoolException.ProtocolLog);
properties.Add("DiagnosticId", PreferencesService.DiagnosticId);
_winoLogger.TrackEvent("IMAP Test Failed", properties);
DialogService.InfoBarMessage(Translator.Info_AccountCreationFailedTitle, testClientPoolException.Message, InfoBarMessageType.Error);
}
catch (ImapClientPoolException clientPoolException) when (clientPoolException.InnerException != null)
2025-02-16 11:54:23 +01:00
{
DialogService.InfoBarMessage(Translator.Info_AccountCreationFailedTitle, clientPoolException.InnerException.Message, InfoBarMessageType.Error);
}
catch (Exception ex)
{
Log.Error(ex, "Failed to create account.");
DialogService.InfoBarMessage(Translator.Info_AccountCreationFailedTitle, ex.Message, InfoBarMessageType.Error);
// Delete account in case of failure.
if (createdAccount != null)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
await AccountService.DeleteAccountAsync(createdAccount);
2024-04-18 01:44:37 +02:00
}
}
2025-02-16 11:54:23 +01:00
finally
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
creationDialog?.Complete(false);
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
[RelayCommand]
private void EditMergedAccounts(MergedAccountProviderDetailViewModel mergedAccountProviderDetailViewModel)
{
Messenger.Send(new BreadcrumbNavigationRequested(mergedAccountProviderDetailViewModel.MergedInbox.Name,
WinoPage.MergedAccountDetailsPage,
mergedAccountProviderDetailViewModel));
}
2024-05-30 02:34:54 +02:00
2025-02-16 11:54:23 +01:00
[RelayCommand(CanExecute = nameof(CanReorderAccounts))]
private Task ReorderAccountsAsync() => MailDialogService.ShowAccountReorderDialogAsync(availableAccounts: Accounts);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override void OnNavigatedFrom(NavigationMode mode, object parameters)
{
base.OnNavigatedFrom(mode, parameters);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
Accounts.CollectionChanged -= AccountCollectionChanged;
2024-05-30 02:34:54 +02:00
2025-02-16 11:54:23 +01:00
PropertyChanged -= PagePropertyChanged;
}
2025-02-16 11:35:43 +01:00
2025-02-16 11:54:23 +01:00
private void AccountCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
OnPropertyChanged(nameof(HasAccountsDefined));
OnPropertyChanged(nameof(UsedAccountsString));
OnPropertyChanged(nameof(IsAccountCreationAlmostOnLimit));
ReorderAccountsCommand.NotifyCanExecuteChanged();
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
private void PagePropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(StartupAccount) && StartupAccount != null)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
PreferencesService.StartupEntityId = StartupAccount.StartupEntityId;
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override async void OnNavigatedTo(NavigationMode mode, object parameters)
{
base.OnNavigatedTo(mode, parameters);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
Accounts.CollectionChanged -= AccountCollectionChanged;
Accounts.CollectionChanged += AccountCollectionChanged;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await InitializeAccountsAsync();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
PropertyChanged -= PagePropertyChanged;
PropertyChanged += PagePropertyChanged;
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
public override async Task InitializeAccountsAsync()
{
StartupAccount = null;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
Accounts.Clear();
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var accounts = await AccountService.GetAccountsAsync().ConfigureAwait(false);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Group accounts and display merged ones at the top.
var groupedAccounts = accounts.GroupBy(a => a.MergedInboxId);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await ExecuteUIThread(() =>
{
foreach (var accountGroup in groupedAccounts)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
var mergedInboxId = accountGroup.Key;
2025-02-16 11:54:23 +01:00
if (mergedInboxId == null)
{
foreach (var account in accountGroup)
2024-04-18 01:44:37 +02:00
{
2025-02-16 11:54:23 +01:00
var accountDetails = GetAccountProviderDetails(account);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
Accounts.Add(accountDetails);
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
else
{
var mergedInbox = accountGroup.First(a => a.MergedInboxId == mergedInboxId).MergedInbox;
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
var holdingAccountProviderDetails = accountGroup.Select(a => GetAccountProviderDetails(a)).ToList();
var mergedAccountViewModel = new MergedAccountProviderDetailViewModel(mergedInbox, holdingAccountProviderDetails);
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
Accounts.Add(mergedAccountViewModel);
2024-04-18 01:44:37 +02:00
}
2025-02-16 11:54:23 +01:00
}
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
// Handle startup entity.
if (PreferencesService.StartupEntityId != null)
{
StartupAccount = Accounts.FirstOrDefault(a => a.StartupEntityId == PreferencesService.StartupEntityId);
}
});
2024-04-18 01:44:37 +02:00
2025-02-16 11:54:23 +01:00
await ManageStorePurchasesAsync().ConfigureAwait(false);
2024-04-18 01:44:37 +02:00
}
}