Removed IWinoSynchronizerFactory from UWP project.

This commit is contained in:
Burak Kaan Köse
2024-07-17 23:22:53 +02:00
parent 329eae3a25
commit a9a9907bc6
14 changed files with 127 additions and 143 deletions

View File

@@ -74,7 +74,6 @@ namespace Wino.Mail.ViewModels
private readonly INotificationBuilder _notificationBuilder;
private readonly IWinoRequestDelegator _winoRequestDelegator;
private readonly IWinoSynchronizerFactory _synchronizerFactory;
private readonly IBackgroundTaskService _backgroundTaskService;
private readonly IMimeFileService _mimeFileService;
@@ -88,7 +87,6 @@ namespace Wino.Mail.ViewModels
public AppShellViewModel(IDialogService dialogService,
IWinoNavigationService navigationService,
IWinoSynchronizerFactory synchronizerFactory,
IBackgroundTaskService backgroundTaskService,
IMimeFileService mimeFileService,
INativeAppService nativeAppService,
@@ -118,7 +116,6 @@ namespace Wino.Mail.ViewModels
PreferencesService = preferencesService;
NavigationService = navigationService;
_synchronizerFactory = synchronizerFactory;
_backgroundTaskService = backgroundTaskService;
_mimeFileService = mimeFileService;
_nativeAppService = nativeAppService;
@@ -791,65 +788,65 @@ namespace Wino.Mail.ViewModels
await _winoRequestDelegator.ExecuteAsync(draftPreperationRequest);
}
public async void Receive(NewSynchronizationRequested message)
{
// TODO: Queue new synchronization for an account.
// Don't send message for sync completion when we execute requests.
// People are usually interested in seeing the notification after they trigger the synchronization.
bool shouldReportSynchronizationResult = message.Options.Type != SynchronizationType.ExecuteRequests;
//bool shouldReportSynchronizationResult = message.Options.Type != SynchronizationType.ExecuteRequests;
var synchronizer = _synchronizerFactory.GetAccountSynchronizer(message.Options.AccountId);
//var synchronizer = _synchronizerFactory.GetAccountSynchronizer(message.Options.AccountId);
if (synchronizer == null) return;
//if (synchronizer == null) return;
var accountId = message.Options.AccountId;
//var accountId = message.Options.AccountId;
message.Options.ProgressListener = this;
//message.Options.ProgressListener = this;
bool isSynchronizationSucceeded = false;
//bool isSynchronizationSucceeded = false;
try
{
// TODO: Cancellation Token
var synchronizationResult = await synchronizer.SynchronizeAsync(message.Options);
//try
//{
// // TODO: Cancellation Token
// var synchronizationResult = await synchronizer.SynchronizeAsync(message.Options);
isSynchronizationSucceeded = synchronizationResult.CompletedState == SynchronizationCompletedState.Success;
// isSynchronizationSucceeded = synchronizationResult.CompletedState == SynchronizationCompletedState.Success;
// Create notification for synchronization result.
if (synchronizationResult.DownloadedMessages.Any())
{
var accountInboxFolder = await _folderService.GetSpecialFolderByAccountIdAsync(message.Options.AccountId, SpecialFolderType.Inbox);
// // Create notification for synchronization result.
// if (synchronizationResult.DownloadedMessages.Any())
// {
// var accountInboxFolder = await _folderService.GetSpecialFolderByAccountIdAsync(message.Options.AccountId, SpecialFolderType.Inbox);
if (accountInboxFolder == null) return;
// if (accountInboxFolder == null) return;
await _notificationBuilder.CreateNotificationsAsync(accountInboxFolder.Id, synchronizationResult.DownloadedMessages);
}
}
catch (AuthenticationAttentionException)
{
await SetAccountAttentionAsync(accountId, AccountAttentionReason.InvalidCredentials);
}
catch (SystemFolderConfigurationMissingException)
{
await SetAccountAttentionAsync(accountId, AccountAttentionReason.MissingSystemFolderConfiguration);
}
catch (OperationCanceledException)
{
DialogService.InfoBarMessage(Translator.Info_SyncCanceledMessage, Translator.Info_SyncCanceledMessage, InfoBarMessageType.Warning);
}
catch (Exception ex)
{
DialogService.InfoBarMessage(Translator.Info_SyncFailedTitle, ex.Message, InfoBarMessageType.Error);
}
finally
{
if (shouldReportSynchronizationResult)
Messenger.Send(new AccountSynchronizationCompleted(accountId,
isSynchronizationSucceeded ? SynchronizationCompletedState.Success : SynchronizationCompletedState.Failed,
message.Options.GroupedSynchronizationTrackingId));
}
// await _notificationBuilder.CreateNotificationsAsync(accountInboxFolder.Id, synchronizationResult.DownloadedMessages);
// }
//}
//catch (AuthenticationAttentionException)
//{
// await SetAccountAttentionAsync(accountId, AccountAttentionReason.InvalidCredentials);
//}
//catch (SystemFolderConfigurationMissingException)
//{
// await SetAccountAttentionAsync(accountId, AccountAttentionReason.MissingSystemFolderConfiguration);
//}
//catch (OperationCanceledException)
//{
// DialogService.InfoBarMessage(Translator.Info_SyncCanceledMessage, Translator.Info_SyncCanceledMessage, InfoBarMessageType.Warning);
//}
//catch (Exception ex)
//{
// DialogService.InfoBarMessage(Translator.Info_SyncFailedTitle, ex.Message, InfoBarMessageType.Error);
//}
//finally
//{
// if (shouldReportSynchronizationResult)
// Messenger.Send(new AccountSynchronizationCompleted(accountId,
// isSynchronizationSucceeded ? SynchronizationCompletedState.Success : SynchronizationCompletedState.Failed,
// message.Options.GroupedSynchronizationTrackingId));
//}
}