diff --git a/Wino.Core.Domain/Translations/en_US/resources.json b/Wino.Core.Domain/Translations/en_US/resources.json index 9b12a335..a439fc5a 100644 --- a/Wino.Core.Domain/Translations/en_US/resources.json +++ b/Wino.Core.Domain/Translations/en_US/resources.json @@ -112,6 +112,9 @@ "DialogMessage_UnsubscribeConfirmationGoToWebsiteMessage": "To stop getting messages from {0}, go to their website to unsubscribe.", "DialogMessage_UnsubscribeConfirmationGoToWebsiteConfirmButton": "Go to website", "DialogMessage_UnsubscribeConfirmationMailtoMessage": "Do you want to stop getting messages from {0}? Wino will unsubscribe for you by sending an email from your email account to {1}.", + "DialogMessage_EnableStartupLaunchTitle": "Enable Startup Launch", + "DialogMessage_EnableStartupLaunchMessage": "Let Wino Mail automatically launch minimized on Windows startup to not miss any notifications.\n\nDo you want to enable startup launch?", + "DialogMessage_EnableStartupLaunchDeniedMessage": "You can enable startup launch from Settings -> App Preferences.", "Dialog_DontAskAgain": "Don't ask again", "CreateAccountAliasDialog_Title": "Create Account Alias", "CreateAccountAliasDialog_Description": "Make sure your outgoing server allows sending mails from this alias.", diff --git a/Wino.Core.Domain/Translator.Designer.cs b/Wino.Core.Domain/Translator.Designer.cs index 2b64bff8..72056b31 100644 --- a/Wino.Core.Domain/Translator.Designer.cs +++ b/Wino.Core.Domain/Translator.Designer.cs @@ -583,6 +583,21 @@ namespace Wino.Core.Domain /// public static string DialogMessage_UnsubscribeConfirmationMailtoMessage => Resources.GetTranslatedString(@"DialogMessage_UnsubscribeConfirmationMailtoMessage"); + /// + /// Enable Startup Launch + /// + public static string DialogMessage_EnableStartupLaunchTitle => Resources.GetTranslatedString(@"DialogMessage_EnableStartupLaunchTitle"); + + /// + /// Let Wino Mail automatically launch minimized on Windows startup to not miss any notifications. Do you want to enable startup launch? + /// + public static string DialogMessage_EnableStartupLaunchMessage => Resources.GetTranslatedString(@"DialogMessage_EnableStartupLaunchMessage"); + + /// + /// You can enable startup launch from Settings -> App Preferences. + /// + public static string DialogMessage_EnableStartupLaunchDeniedMessage => Resources.GetTranslatedString(@"DialogMessage_EnableStartupLaunchDeniedMessage"); + /// /// Don't ask again /// diff --git a/Wino.Mail.ViewModels/AppShellViewModel.cs b/Wino.Mail.ViewModels/AppShellViewModel.cs index b87bd135..342786e1 100644 --- a/Wino.Mail.ViewModels/AppShellViewModel.cs +++ b/Wino.Mail.ViewModels/AppShellViewModel.cs @@ -60,6 +60,8 @@ namespace Wino.Mail.ViewModels #endregion + private const string IsActivateStartupLaunchAskedKey = nameof(IsActivateStartupLaunchAskedKey); + public IStatePersistanceService StatePersistenceService { get; } public IWinoServerConnectionManager ServerConnectionManager { get; } public IPreferencesService PreferencesService { get; } @@ -67,6 +69,7 @@ namespace Wino.Mail.ViewModels private readonly IFolderService _folderService; private readonly IConfigurationService _configurationService; + private readonly IStartupBehaviorService _startupBehaviorService; private readonly IAccountService _accountService; private readonly IContextMenuItemService _contextMenuItemService; private readonly IStoreRatingService _storeRatingService; @@ -101,7 +104,8 @@ namespace Wino.Mail.ViewModels IFolderService folderService, IStatePersistanceService statePersistanceService, IWinoServerConnectionManager serverConnectionManager, - IConfigurationService configurationService) : base(dialogService) + IConfigurationService configurationService, + IStartupBehaviorService startupBehaviorService) : base(dialogService) { StatePersistenceService = statePersistanceService; ServerConnectionManager = serverConnectionManager; @@ -119,6 +123,7 @@ namespace Wino.Mail.ViewModels NavigationService = navigationService; _configurationService = configurationService; + _startupBehaviorService = startupBehaviorService; _backgroundTaskService = backgroundTaskService; _mimeFileService = mimeFileService; _nativeAppService = nativeAppService; @@ -239,9 +244,41 @@ namespace Wino.Mail.ViewModels await ProcessLaunchOptionsAsync(); await ForceAllAccountSynchronizationsAsync(); + await MakeSureEnableStartupLaunchAsync(); ConfigureBackgroundTasks(); } + private async Task MakeSureEnableStartupLaunchAsync() + { + if (!_configurationService.Get(IsActivateStartupLaunchAskedKey, false)) + { + bool isAccepted = await DialogService.ShowWinoCustomMessageDialogAsync(Translator.DialogMessage_EnableStartupLaunchTitle, + Translator.DialogMessage_EnableStartupLaunchMessage, + Translator.Buttons_Yes, + WinoCustomMessageDialogIcon.Information, + Translator.Buttons_No); + + bool shouldDisplayLaterOnMessage = !isAccepted; + + if (isAccepted) + { + var behavior = await _startupBehaviorService.ToggleStartupBehavior(true); + + shouldDisplayLaterOnMessage = behavior != StartupBehaviorResult.Enabled; + } + + if (shouldDisplayLaterOnMessage) + { + await DialogService.ShowWinoCustomMessageDialogAsync(Translator.DialogMessage_EnableStartupLaunchTitle, + Translator.DialogMessage_EnableStartupLaunchDeniedMessage, + Translator.Buttons_Close, + WinoCustomMessageDialogIcon.Information); + } + + _configurationService.Set(IsActivateStartupLaunchAskedKey, true); + } + } + private void ConfigureBackgroundTasks() { try @@ -809,16 +846,11 @@ namespace Wino.Mail.ViewModels protected override async void OnAccountUpdated(MailAccount updatedAccount) { - await ExecuteUIThread(async () => + await ExecuteUIThread(() => { if (MenuItems.TryGetAccountMenuItem(updatedAccount.Id, out IAccountMenuItem foundAccountMenuItem)) { foundAccountMenuItem.UpdateAccount(updatedAccount); - - if (latestSelectedAccountMenuItem == foundAccountMenuItem) - { - await ChangeLoadedAccountAsync(foundAccountMenuItem, false); - } } }); }