diff --git a/Wino.Core.Domain/Enums/AccountCreationDialogState.cs b/Wino.Core.Domain/Enums/AccountCreationDialogState.cs index 0cc10546..2e91d743 100644 --- a/Wino.Core.Domain/Enums/AccountCreationDialogState.cs +++ b/Wino.Core.Domain/Enums/AccountCreationDialogState.cs @@ -5,6 +5,7 @@ public enum AccountCreationDialogState Idle, SigningIn, PreparingFolders, + CalendarMetadataFetch, Completed, ManuelSetupWaiting, TestingConnection, diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json index 00f88c28..ec1838e5 100644 --- a/Wino.Core.Domain/Translations/en_US/resources.json +++ b/Wino.Core.Domain/Translations/en_US/resources.json @@ -8,6 +8,7 @@ "AccountCacheReset_Message": "This account requires full re-sychronization to continue working. Please wait while Wino re-synchronizes your messages...", "AccountContactNameYou": "You", "AccountCreationDialog_Completed": "all done", + "AccountCreationDialog_FetchingCalendarMetadata": "Fetching calendar details.", "AccountCreationDialog_FetchingEvents": "Fetching calendar events.", "AccountCreationDialog_FetchingProfileInformation": "Fetching profile details.", "AccountCreationDialog_GoogleAuthHelpClipboardText_Row0": "If your browser did not launch automatically to complete authentication:", @@ -242,6 +243,7 @@ "Exception_CustomThemeMissingName": "You must provide a name.", "Exception_CustomThemeMissingWallpaper": "You must provide a custom background image.", "Exception_FailedToSynchronizeAliases": "Failed to synchronize aliases", + "Exception_FailedToSynchronizeCalendarMetadata": "Failed to synchronize calendar details", "Exception_FailedToSynchronizeFolders": "Failed to synchronize folders", "Exception_FailedToSynchronizeProfileInformation": "Failed to synchronize profile information", "Exception_GoogleAuthCallbackNull": "Callback uri is null on activation.", diff --git a/Wino.Core/Synchronizers/GmailSynchronizer.cs b/Wino.Core/Synchronizers/GmailSynchronizer.cs index 08926fc2..2ee9eb3e 100644 --- a/Wino.Core/Synchronizers/GmailSynchronizer.cs +++ b/Wino.Core/Synchronizers/GmailSynchronizer.cs @@ -495,6 +495,9 @@ public class GmailSynchronizer : WinoSynchronizer c.RemoteCalendarId, StringComparer.OrdinalIgnoreCase); diff --git a/Wino.Core/Synchronizers/OutlookSynchronizer.cs b/Wino.Core/Synchronizers/OutlookSynchronizer.cs index b93924b1..7a5c73d4 100644 --- a/Wino.Core/Synchronizers/OutlookSynchronizer.cs +++ b/Wino.Core/Synchronizers/OutlookSynchronizer.cs @@ -1988,6 +1988,9 @@ public class OutlookSynchronizer : WinoSynchronizer c.IsSynchronizationEnabled) .ToList(); diff --git a/Wino.Mail.ViewModels/AccountManagementViewModel.cs b/Wino.Mail.ViewModels/AccountManagementViewModel.cs index ee4930a0..63f1e875 100644 --- a/Wino.Mail.ViewModels/AccountManagementViewModel.cs +++ b/Wino.Mail.ViewModels/AccountManagementViewModel.cs @@ -14,6 +14,7 @@ using Wino.Core.Domain.Exceptions; using Wino.Core.Domain.Interfaces; using Wino.Core.Domain.Models.Calendar; using Wino.Core.Domain.Models.Navigation; +using Wino.Core.Domain.Models.Synchronization; using Wino.Core.Services; using Wino.Core.ViewModels; using Wino.Core.ViewModels.Data; @@ -87,6 +88,7 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel MailAccount createdAccount = null; IAccountCreationDialog creationDialog = null; + bool creationDialogClosed = false; try { @@ -225,6 +227,21 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel if (folderSynchronizationResult == null || folderSynchronizationResult.CompletedState != SynchronizationCompletedState.Success) throw new Exception(Translator.Exception_FailedToSynchronizeFolders); + if (createdAccount.IsCalendarAccessGranted) + { + if (creationDialog != null) + await ExecuteUIThread(() => creationDialog.State = AccountCreationDialogState.CalendarMetadataFetch); + + var calendarMetadataSynchronizationResult = await SynchronizationManager.Instance.SynchronizeCalendarAsync(new CalendarSynchronizationOptions + { + AccountId = createdAccount.Id, + Type = CalendarSynchronizationType.CalendarMetadata + }); + + if (calendarMetadataSynchronizationResult == null || calendarMetadataSynchronizationResult.CompletedState != SynchronizationCompletedState.Success) + throw new Exception(Translator.Exception_FailedToSynchronizeCalendarMetadata); + } + // Sync aliases if supported. if (createdAccount.IsAliasSyncSupported) { @@ -242,6 +259,12 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel await AccountService.CreateRootAliasAsync(createdAccount.Id, createdAccount.Address); } + if (creationDialog != null) + { + await ExecuteUIThread(() => creationDialog.Complete(false)); + creationDialogClosed = true; + } + // Send changes to listeners. await ExecuteUIThread(() => ReportUIChange(new AccountCreatedMessage(createdAccount))); @@ -299,7 +322,12 @@ public partial class AccountManagementViewModel : AccountManagementPageViewModel } finally { - await ExecuteUIThread(() => { creationDialog?.Complete(false); }); + if (creationDialog != null && !creationDialogClosed) + { + bool isCanceled = false; + await ExecuteUIThread(() => isCanceled = creationDialog.State == AccountCreationDialogState.Canceled); + await ExecuteUIThread(() => creationDialog.Complete(isCanceled)); + } } } diff --git a/Wino.Mail.ViewModels/MailAppShellViewModel.cs b/Wino.Mail.ViewModels/MailAppShellViewModel.cs index abb4c25c..f2d35f07 100644 --- a/Wino.Mail.ViewModels/MailAppShellViewModel.cs +++ b/Wino.Mail.ViewModels/MailAppShellViewModel.cs @@ -1095,6 +1095,17 @@ public partial class MailAppShellViewModel : MailBaseViewModel, Messenger.Send(new NewMailSynchronizationRequested(options)); + if (createdAccount.IsCalendarAccessGranted) + { + var calendarOptions = new CalendarSynchronizationOptions() + { + AccountId = createdAccount.Id, + Type = CalendarSynchronizationType.CalendarEvents + }; + + Messenger.Send(new NewCalendarSynchronizationRequested(calendarOptions)); + } + try { await _nativeAppService.PinAppToTaskbarAsync(); diff --git a/Wino.Mail.WinUI/Controls/AccountCreationDialogControl.xaml b/Wino.Mail.WinUI/Controls/AccountCreationDialogControl.xaml index de05439f..17ea54df 100644 --- a/Wino.Mail.WinUI/Controls/AccountCreationDialogControl.xaml +++ b/Wino.Mail.WinUI/Controls/AccountCreationDialogControl.xaml @@ -113,7 +113,15 @@ - + + + + + + + + +