Toast actions.
This commit is contained in:
@@ -42,6 +42,7 @@ public class SynchronizationManager : ISynchronizationManager
|
||||
/// <summary>
|
||||
/// Initializes the SynchronizationManager with required dependencies.
|
||||
/// This must be called before using any other methods.
|
||||
/// Note: Synchronizers are created lazily to avoid requiring window handles during app initialization.
|
||||
/// </summary>
|
||||
/// <param name="synchronizerFactory">Factory for creating synchronizers</param>
|
||||
/// <param name="imapTestService">Service for testing IMAP connectivity</param>
|
||||
@@ -65,28 +66,11 @@ public class SynchronizationManager : ISynchronizationManager
|
||||
_authenticationProvider = authenticationProvider ?? throw new ArgumentNullException(nameof(authenticationProvider));
|
||||
_notificationBuilder = notificationBuilder ?? throw new ArgumentNullException(nameof(notificationBuilder));
|
||||
|
||||
// Get all accounts and create synchronizers for them
|
||||
var accounts = await _accountService.GetAccountsAsync();
|
||||
|
||||
foreach (var account in accounts)
|
||||
{
|
||||
try
|
||||
{
|
||||
var synchronizer = _concreteSynchronizerFactory.CreateNewSynchronizer(account);
|
||||
_synchronizerCache.TryAdd(account.Id, synchronizer);
|
||||
|
||||
_logger.Information("Created synchronizer for account {AccountName} ({AccountId})",
|
||||
account.Name, account.Id);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.Error(ex, "Failed to create synchronizer for account {AccountName} ({AccountId})",
|
||||
account.Name, account.Id);
|
||||
}
|
||||
}
|
||||
// DO NOT create synchronizers here to avoid requiring window handles during initialization.
|
||||
// Synchronizers will be created lazily when first accessed via GetOrCreateSynchronizerAsync.
|
||||
|
||||
_isInitialized = true;
|
||||
_logger.Information("SynchronizationManager initialized with {Count} synchronizers", _synchronizerCache.Count);
|
||||
_logger.Information("SynchronizationManager dependencies initialized. Synchronizers will be created lazily.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -20,16 +20,14 @@ public class SynchronizerFactory : ISynchronizerFactory
|
||||
private readonly IOutlookChangeProcessor _outlookChangeProcessor;
|
||||
private readonly IGmailChangeProcessor _gmailChangeProcessor;
|
||||
private readonly IImapChangeProcessor _imapChangeProcessor;
|
||||
private readonly IOutlookAuthenticator _outlookAuthenticator;
|
||||
private readonly IGmailAuthenticator _gmailAuthenticator;
|
||||
private readonly IAuthenticationProvider _authenticationProvider;
|
||||
|
||||
private readonly List<IWinoSynchronizerBase> synchronizerCache = new();
|
||||
|
||||
public SynchronizerFactory(IOutlookChangeProcessor outlookChangeProcessor,
|
||||
IGmailChangeProcessor gmailChangeProcessor,
|
||||
IImapChangeProcessor imapChangeProcessor,
|
||||
IOutlookAuthenticator outlookAuthenticator,
|
||||
IGmailAuthenticator gmailAuthenticator,
|
||||
IAuthenticationProvider authenticationProvider,
|
||||
IAccountService accountService,
|
||||
IImapSynchronizationStrategyProvider imapSynchronizationStrategyProvider,
|
||||
IApplicationConfiguration applicationConfiguration,
|
||||
@@ -39,8 +37,7 @@ public class SynchronizerFactory : ISynchronizerFactory
|
||||
_outlookChangeProcessor = outlookChangeProcessor;
|
||||
_gmailChangeProcessor = gmailChangeProcessor;
|
||||
_imapChangeProcessor = imapChangeProcessor;
|
||||
_outlookAuthenticator = outlookAuthenticator;
|
||||
_gmailAuthenticator = gmailAuthenticator;
|
||||
_authenticationProvider = authenticationProvider;
|
||||
_accountService = accountService;
|
||||
_imapSynchronizationStrategyProvider = imapSynchronizationStrategyProvider;
|
||||
_applicationConfiguration = applicationConfiguration;
|
||||
@@ -75,9 +72,11 @@ public class SynchronizerFactory : ISynchronizerFactory
|
||||
switch (providerType)
|
||||
{
|
||||
case Domain.Enums.MailProviderType.Outlook:
|
||||
return new OutlookSynchronizer(mailAccount, _outlookAuthenticator, _outlookChangeProcessor, _outlookSynchronizerErrorHandlerFactory);
|
||||
var outlookAuthenticator = _authenticationProvider.GetAuthenticator(Domain.Enums.MailProviderType.Outlook) as IOutlookAuthenticator;
|
||||
return new OutlookSynchronizer(mailAccount, outlookAuthenticator, _outlookChangeProcessor, _outlookSynchronizerErrorHandlerFactory);
|
||||
case Domain.Enums.MailProviderType.Gmail:
|
||||
return new GmailSynchronizer(mailAccount, _gmailAuthenticator, _gmailChangeProcessor, _gmailSynchronizerErrorHandlerFactory);
|
||||
var gmailAuthenticator = _authenticationProvider.GetAuthenticator(Domain.Enums.MailProviderType.Gmail) as IGmailAuthenticator;
|
||||
return new GmailSynchronizer(mailAccount, gmailAuthenticator, _gmailChangeProcessor, _gmailSynchronizerErrorHandlerFactory);
|
||||
case Domain.Enums.MailProviderType.IMAP4:
|
||||
return new ImapSynchronizer(mailAccount, _imapChangeProcessor, _imapSynchronizationStrategyProvider, _applicationConfiguration);
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user