diff --git a/App/App.xaml.cs b/App/App.xaml.cs index 3165e2f..a07af43 100644 --- a/App/App.xaml.cs +++ b/App/App.xaml.cs @@ -27,7 +27,7 @@ namespace Coder.Desktop.App; -public partial class App : Application, IDispatcherQueueManager, INotificationHandler +public partial class App : Application, IDispatcherQueueManager, IDefaultNotificationHandler { private const string MutagenControllerConfigSection = "MutagenController"; private const string UpdaterConfigSection = "Updater"; @@ -91,7 +91,7 @@ public App() services.AddSingleton(); services.AddSingleton(_ => this); - services.AddSingleton(_ => this); + services.AddSingleton(_ => this); services.AddSingleton(_ => new WindowsCredentialBackend(WindowsCredentialBackend.CoderCredentialsTargetName)); services.AddSingleton(); @@ -337,12 +337,8 @@ public void RunInUiThread(DispatcherQueueHandler action) dispatcherQueue.TryEnqueue(action); } - public void HandleNotificationActivation(IDictionary args) + public void HandleNotificationActivation(IDictionary _) { - var app = (App)Current; - if (app != null && app.TrayWindow != null) - { - app.TrayWindow.Tray_Open(); - } + TrayWindow?.Tray_Open(); } } diff --git a/App/Services/UserNotifier.cs b/App/Services/UserNotifier.cs index e759c50..27f924d 100644 --- a/App/Services/UserNotifier.cs +++ b/App/Services/UserNotifier.cs @@ -15,6 +15,12 @@ public interface INotificationHandler public void HandleNotificationActivation(IDictionary args); } +// This interface is meant to protect the default +// notification handler from being overriden by DI. +public interface IDefaultNotificationHandler : INotificationHandler +{ +} + public interface IUserNotifier : INotificationHandler, IAsyncDisposable { public void RegisterHandler(string name, INotificationHandler handler); @@ -46,7 +52,7 @@ public class UserNotifier : IUserNotifier private ConcurrentDictionary Handlers { get; } = new(); public UserNotifier(ILogger logger, IDispatcherQueueManager dispatcherQueueManager, - INotificationHandler notificationHandler) + IDefaultNotificationHandler notificationHandler) { _logger = logger; _dispatcherQueueManager = dispatcherQueueManager; diff --git a/App/Views/TrayWindow.xaml.cs b/App/Views/TrayWindow.xaml.cs index 7269e68..72ab6cc 100644 --- a/App/Views/TrayWindow.xaml.cs +++ b/App/Views/TrayWindow.xaml.cs @@ -152,10 +152,13 @@ private void SetPageByState(RpcModel rpcModel, CredentialModel credentialModel, } } + /// + /// This method is called when the state changes, but we don't want to notify + /// the user if the state hasn't changed. + /// + /// private void MaybeNotifyUser(RpcModel rpcModel) { - // This method is called when the state changes, but we don't want to notify - // the user if the state hasn't changed. var isRpcLifecycleChanged = rpcModel.RpcLifecycle == RpcLifecycle.Disconnected && curRpcLifecycle != rpcModel.RpcLifecycle; var isVpnLifecycleChanged = (rpcModel.VpnLifecycle == VpnLifecycle.Started || rpcModel.VpnLifecycle == VpnLifecycle.Stopped) && curVpnLifecycle != rpcModel.VpnLifecycle; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy