diff --git a/Wino.Core.UWP/Services/WinoServerConnectionManager.cs b/Wino.Core.UWP/Services/WinoServerConnectionManager.cs index f0551888..9aaca3ed 100644 --- a/Wino.Core.UWP/Services/WinoServerConnectionManager.cs +++ b/Wino.Core.UWP/Services/WinoServerConnectionManager.cs @@ -24,7 +24,7 @@ namespace Wino.Core.UWP.Services { public class WinoServerConnectionManager : IWinoServerConnectionManager, - IRecipient + IRecipient { private const int ServerConnectionTimeoutMs = 5000; @@ -101,7 +101,7 @@ namespace Wino.Core.UWP.Services // Connection establishment handler is in App.xaml.cs OnBackgroundActivated. // Once the connection is established, the handler will set the Connection property - // and WinoServerConnectionEstrablished will be fired by the messenger. + // and WinoServerConnectionEstablished will be fired by the messenger. await _connectionTaskCompletionSource.Task.WaitAsync(connectionCancellationToken.Token); } @@ -305,7 +305,7 @@ namespace Wino.Core.UWP.Services } } - public void Receive(WinoServerConnectionEstrablished message) + public void Receive(WinoServerConnectionEstablished message) { if (_connectionTaskCompletionSource != null) { diff --git a/Wino.Mail/App.xaml.cs b/Wino.Mail/App.xaml.cs index b282762d..c4e2d1ad 100644 --- a/Wino.Mail/App.xaml.cs +++ b/Wino.Mail/App.xaml.cs @@ -10,6 +10,7 @@ using Microsoft.AppCenter; using Microsoft.AppCenter.Analytics; using Microsoft.AppCenter.Crashes; using Microsoft.Extensions.DependencyInjection; +using Nito.AsyncEx; using Serilog; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; @@ -146,7 +147,6 @@ namespace Wino private void RegisterActivationHandlers(IServiceCollection services) { services.AddTransient(); - // services.AddTransient(); services.AddTransient(); services.AddTransient(); } @@ -283,19 +283,18 @@ namespace Wino _appServiceConnectionManager.Connection = appServiceTriggerDetails.AppServiceConnection; - WeakReferenceMessenger.Default.Send(new WinoServerConnectionEstrablished()); + WeakReferenceMessenger.Default.Send(new WinoServerConnectionEstablished()); } } else if (args.TaskInstance.TriggerDetails is ToastNotificationActionTriggerDetail toastNotificationActionTriggerDetail) { - await InitializeServicesAsync(); - // Notification action is triggered and the app is not running. toastActionBackgroundTaskDeferral = args.TaskInstance.GetDeferral(); - args.TaskInstance.Canceled += OnToastActionClickedBackgroundTaskCanceled; + await InitializeServicesAsync(); + var toastArguments = ToastArguments.Parse(toastNotificationActionTriggerDetail.Argument); // All toast activation mail actions are handled here like mark as read or delete. @@ -364,13 +363,7 @@ namespace Wino private bool IsInteractiveLaunchArgs(object args) => args is IActivatedEventArgs; - private async Task InitializeServicesAsync() - { - foreach (var service in initializeServices) - { - await service.InitializeAsync(); - } - } + private Task InitializeServicesAsync() => initializeServices.Select(a => a.InitializeAsync()).WhenAll(); private async Task ActivateWinoAsync(object args) { @@ -428,7 +421,7 @@ namespace Wino { sender.Canceled -= OnConnectionBackgroundTaskCanceled; - Log.Information($"Background task {sender.Task.Name} was canceled. Reason: {reason}"); + Log.Information($"Server connection background task '{sender.Task.Name}' was canceled. Reason: {reason}"); await _appServiceConnectionManager.DisconnectAsync(); diff --git a/Wino.Messages/Client/Connection/WinoServerConnectionEstrablished.cs b/Wino.Messages/Client/Connection/WinoServerConnectionEstrablished.cs index 2f9d0c2b..e2f5dd24 100644 --- a/Wino.Messages/Client/Connection/WinoServerConnectionEstrablished.cs +++ b/Wino.Messages/Client/Connection/WinoServerConnectionEstrablished.cs @@ -3,5 +3,5 @@ /// /// When client established a healthy connection to the server. /// - public record WinoServerConnectionEstrablished; + public record WinoServerConnectionEstablished; }