Removed IWinoSynchronizerFactory from UWP project.
This commit is contained in:
@@ -18,7 +18,6 @@ namespace Wino.Mail.ViewModels
|
||||
{
|
||||
public partial class AccountDetailsPageViewModel : BaseViewModel
|
||||
{
|
||||
private readonly IWinoSynchronizerFactory _synchronizerFactory;
|
||||
private readonly IAccountService _accountService;
|
||||
private readonly IFolderService _folderService;
|
||||
|
||||
@@ -44,11 +43,9 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
|
||||
public AccountDetailsPageViewModel(IDialogService dialogService,
|
||||
IWinoSynchronizerFactory synchronizerFactory,
|
||||
IAccountService accountService,
|
||||
IFolderService folderService) : base(dialogService)
|
||||
{
|
||||
_synchronizerFactory = synchronizerFactory;
|
||||
_accountService = accountService;
|
||||
_folderService = folderService;
|
||||
}
|
||||
@@ -98,10 +95,7 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
await _accountService.DeleteAccountAsync(Account);
|
||||
|
||||
_synchronizerFactory.DeleteSynchronizer(Account);
|
||||
|
||||
// TODO: Clear existing requests.
|
||||
// _synchronizationWorker.ClearRequests(Account.Id);
|
||||
// TODO: Server: Cancel ongoing calls from server for this account.
|
||||
|
||||
DialogService.InfoBarMessage(Translator.Info_AccountDeletedTitle, string.Format(Translator.Info_AccountDeletedMessage, Account.Name), InfoBarMessageType.Success);
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ using Wino.Core.Domain.Exceptions;
|
||||
using Wino.Core.Domain.Interfaces;
|
||||
using Wino.Core.Domain.Models.Navigation;
|
||||
using Wino.Core.Domain.Models.Store;
|
||||
using Wino.Core.Domain.Models.Synchronization;
|
||||
using Wino.Core.Messages.Authorization;
|
||||
using Wino.Core.Messages.Navigation;
|
||||
using Wino.Mail.ViewModels.Data;
|
||||
@@ -35,7 +34,6 @@ namespace Wino.Mail.ViewModels
|
||||
private readonly IStoreManagementService _storeManagementService;
|
||||
private readonly IPreferencesService _preferencesService;
|
||||
private readonly IAuthenticationProvider _authenticationProvider;
|
||||
private readonly IWinoSynchronizerFactory _synchronizerFactory;
|
||||
|
||||
public ObservableCollection<IAccountProviderDetailViewModel> Accounts { get; set; } = [];
|
||||
|
||||
@@ -60,7 +58,6 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
public AccountManagementViewModel(IDialogService dialogService,
|
||||
IWinoNavigationService navigationService,
|
||||
IWinoSynchronizerFactory synchronizerFactory,
|
||||
IAccountService accountService,
|
||||
IProviderService providerService,
|
||||
IFolderService folderService,
|
||||
@@ -69,7 +66,6 @@ namespace Wino.Mail.ViewModels
|
||||
IAuthenticationProvider authenticationProvider) : base(dialogService)
|
||||
{
|
||||
_accountService = accountService;
|
||||
_synchronizerFactory = synchronizerFactory;
|
||||
_dialogService = dialogService;
|
||||
_providerService = providerService;
|
||||
_folderService = folderService;
|
||||
@@ -205,29 +201,31 @@ namespace Wino.Mail.ViewModels
|
||||
// Local account has been created.
|
||||
// Create new synchronizer and start synchronization.
|
||||
|
||||
var synchronizer = _synchronizerFactory.CreateNewSynchronizer(createdAccount);
|
||||
// TODO: Server: Make sure that server synchronizes folders and sends back the result.
|
||||
|
||||
if (creationDialog is ICustomServerAccountCreationDialog customServerAccountCreationDialog)
|
||||
customServerAccountCreationDialog.ShowPreparingFolders();
|
||||
else
|
||||
creationDialog.State = AccountCreationDialogState.PreparingFolders;
|
||||
//var synchronizer = _synchronizerFactory.CreateNewSynchronizer(createdAccount);
|
||||
|
||||
var options = new SynchronizationOptions()
|
||||
{
|
||||
AccountId = createdAccount.Id,
|
||||
Type = SynchronizationType.FoldersOnly
|
||||
};
|
||||
//if (creationDialog is ICustomServerAccountCreationDialog customServerAccountCreationDialog)
|
||||
// customServerAccountCreationDialog.ShowPreparingFolders();
|
||||
//else
|
||||
// creationDialog.State = AccountCreationDialogState.PreparingFolders;
|
||||
|
||||
var synchronizationResult = await synchronizer.SynchronizeAsync(options);
|
||||
//var options = new SynchronizationOptions()
|
||||
//{
|
||||
// AccountId = createdAccount.Id,
|
||||
// Type = SynchronizationType.FoldersOnly
|
||||
//};
|
||||
|
||||
if (synchronizationResult.CompletedState != SynchronizationCompletedState.Success)
|
||||
throw new Exception(Translator.Exception_FailedToSynchronizeFolders);
|
||||
//var synchronizationResult = await synchronizer.SynchronizeAsync(options);
|
||||
|
||||
// Check if Inbox folder is available for the account after synchronization.
|
||||
var isInboxAvailable = await _folderService.IsInboxAvailableForAccountAsync(createdAccount.Id);
|
||||
//if (synchronizationResult.CompletedState != SynchronizationCompletedState.Success)
|
||||
// throw new Exception(Translator.Exception_FailedToSynchronizeFolders);
|
||||
|
||||
if (!isInboxAvailable)
|
||||
throw new Exception(Translator.Exception_InboxNotAvailable);
|
||||
//// Check if Inbox folder is available for the account after synchronization.
|
||||
//var isInboxAvailable = await _folderService.IsInboxAvailableForAccountAsync(createdAccount.Id);
|
||||
|
||||
//if (!isInboxAvailable)
|
||||
// throw new Exception(Translator.Exception_InboxNotAvailable);
|
||||
|
||||
// Send changes to listeners.
|
||||
ReportUIChange(new AccountCreatedMessage(createdAccount));
|
||||
|
||||
@@ -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));
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
private readonly IMailService _mailService;
|
||||
private readonly IFolderService _folderService;
|
||||
private readonly IWinoSynchronizerFactory _winoSynchronizerFactory;
|
||||
private readonly IThreadingStrategyProvider _threadingStrategyProvider;
|
||||
private readonly IContextMenuItemService _contextMenuItemService;
|
||||
private readonly IWinoRequestDelegator _winoRequestDelegator;
|
||||
@@ -143,7 +142,6 @@ namespace Wino.Mail.ViewModels
|
||||
IMailService mailService,
|
||||
IStatePersistanceService statePersistanceService,
|
||||
IFolderService folderService,
|
||||
IWinoSynchronizerFactory winoSynchronizerFactory,
|
||||
IThreadingStrategyProvider threadingStrategyProvider,
|
||||
IContextMenuItemService contextMenuItemService,
|
||||
IWinoRequestDelegator winoRequestDelegator,
|
||||
@@ -156,7 +154,6 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
_mailService = mailService;
|
||||
_folderService = folderService;
|
||||
_winoSynchronizerFactory = winoSynchronizerFactory;
|
||||
_threadingStrategyProvider = threadingStrategyProvider;
|
||||
_contextMenuItemService = contextMenuItemService;
|
||||
_winoRequestDelegator = winoRequestDelegator;
|
||||
@@ -977,17 +974,19 @@ namespace Wino.Mail.ViewModels
|
||||
|
||||
foreach (var accountId in accountIds)
|
||||
{
|
||||
var synchronizer = _winoSynchronizerFactory.GetAccountSynchronizer(accountId);
|
||||
// TODO: Server: Check whether account is already synchronizing from the server.
|
||||
|
||||
if (synchronizer == null) continue;
|
||||
//var synchronizer = _winoSynchronizerFactory.GetAccountSynchronizer(accountId);
|
||||
|
||||
bool isAccountSynchronizing = synchronizer.State != AccountSynchronizerState.Idle;
|
||||
//if (synchronizer == null) continue;
|
||||
|
||||
if (isAccountSynchronizing)
|
||||
{
|
||||
isAnyAccountSynchronizing = true;
|
||||
break;
|
||||
}
|
||||
//bool isAccountSynchronizing = synchronizer.State != AccountSynchronizerState.Idle;
|
||||
|
||||
//if (isAccountSynchronizing)
|
||||
//{
|
||||
// isAnyAccountSynchronizing = true;
|
||||
// break;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace Wino.Mail.ViewModels
|
||||
private readonly IMimeFileService _mimeFileService;
|
||||
private readonly Core.Domain.Interfaces.IMailService _mailService;
|
||||
private readonly IFileService _fileService;
|
||||
private readonly IWinoSynchronizerFactory _winoSynchronizerFactory;
|
||||
private readonly IWinoRequestDelegator _requestDelegator;
|
||||
private readonly IClipboardService _clipboardService;
|
||||
private readonly IUnsubscriptionService _unsubscriptionService;
|
||||
@@ -124,7 +123,6 @@ namespace Wino.Mail.ViewModels
|
||||
IMimeFileService mimeFileService,
|
||||
Core.Domain.Interfaces.IMailService mailService,
|
||||
IFileService fileService,
|
||||
IWinoSynchronizerFactory winoSynchronizerFactory,
|
||||
IWinoRequestDelegator requestDelegator,
|
||||
IStatePersistanceService statePersistanceService,
|
||||
IClipboardService clipboardService,
|
||||
@@ -141,7 +139,6 @@ namespace Wino.Mail.ViewModels
|
||||
_mimeFileService = mimeFileService;
|
||||
_mailService = mailService;
|
||||
_fileService = fileService;
|
||||
_winoSynchronizerFactory = winoSynchronizerFactory;
|
||||
_requestDelegator = requestDelegator;
|
||||
}
|
||||
|
||||
@@ -344,30 +341,31 @@ namespace Wino.Mail.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private async Task HandleSingleItemDownloadAsync(MailItemViewModel mailItemViewModel)
|
||||
{
|
||||
var synchronizer = _winoSynchronizerFactory.GetAccountSynchronizer(mailItemViewModel.AssignedAccount.Id);
|
||||
// TODO: Server: Download single mime and report back the item here.
|
||||
|
||||
try
|
||||
{
|
||||
// To show the progress on the UI.
|
||||
CurrentDownloadPercentage = 1;
|
||||
//var synchronizer = _winoSynchronizerFactory.GetAccountSynchronizer(mailItemViewModel.AssignedAccount.Id);
|
||||
|
||||
await synchronizer.DownloadMissingMimeMessageAsync(mailItemViewModel.MailCopy, this, renderCancellationTokenSource.Token);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
Log.Information("MIME download is canceled.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DialogService.InfoBarMessage(Translator.GeneralTitle_Error, ex.Message, InfoBarMessageType.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ResetProgress();
|
||||
}
|
||||
//try
|
||||
//{
|
||||
// // To show the progress on the UI.
|
||||
// CurrentDownloadPercentage = 1;
|
||||
|
||||
// await synchronizer.DownloadMissingMimeMessageAsync(mailItemViewModel.MailCopy, this, renderCancellationTokenSource.Token);
|
||||
//}
|
||||
//catch (OperationCanceledException)
|
||||
//{
|
||||
// Log.Information("MIME download is canceled.");
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// DialogService.InfoBarMessage(Translator.GeneralTitle_Error, ex.Message, InfoBarMessageType.Error);
|
||||
//}
|
||||
//finally
|
||||
//{
|
||||
// ResetProgress();
|
||||
//}
|
||||
}
|
||||
|
||||
private async Task RenderAsync(MailItemViewModel mailItemViewModel, CancellationToken cancellationToken = default)
|
||||
|
||||
Reference in New Issue
Block a user