Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: fixed user notifier default notification handler#141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ibetitsmike merged 2 commits intomainfrommike/notifier-cleanup
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletionsApp/App.xaml.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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";
Expand DownExpand Up@@ -91,7 +91,7 @@ public App()
services.AddSingleton<IAgentApiClientFactory, AgentApiClientFactory>();

services.AddSingleton<IDispatcherQueueManager>(_ => this);
services.AddSingleton<INotificationHandler>(_ => this);
services.AddSingleton<IDefaultNotificationHandler>(_ => this);
services.AddSingleton<ICredentialBackend>(_ =>
new WindowsCredentialBackend(WindowsCredentialBackend.CoderCredentialsTargetName));
services.AddSingleton<ICredentialManager, CredentialManager>();
Expand DownExpand Up@@ -337,12 +337,8 @@ public void RunInUiThread(DispatcherQueueHandler action)
dispatcherQueue.TryEnqueue(action);
}

public void HandleNotificationActivation(IDictionary<string, string>args)
public void HandleNotificationActivation(IDictionary<string, string>_)
{
var app = (App)Current;
if (app != null && app.TrayWindow != null)
{
app.TrayWindow.Tray_Open();
}
TrayWindow?.Tray_Open();
}
}
8 changes: 7 additions & 1 deletionApp/Services/UserNotifier.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,12 @@ public interface INotificationHandler
public void HandleNotificationActivation(IDictionary<string, string> 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);
Expand DownExpand Up@@ -46,7 +52,7 @@ public class UserNotifier : IUserNotifier
private ConcurrentDictionary<string, INotificationHandler> Handlers { get; } = new();

public UserNotifier(ILogger<UserNotifier> logger, IDispatcherQueueManager dispatcherQueueManager,
INotificationHandler notificationHandler)
IDefaultNotificationHandler notificationHandler)
{
_logger = logger;
_dispatcherQueueManager = dispatcherQueueManager;
Expand Down
7 changes: 5 additions & 2 deletionsApp/Views/TrayWindow.xaml.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -152,10 +152,13 @@ private void SetPageByState(RpcModel rpcModel, CredentialModel credentialModel,
}
}

/// <summary>
/// This method is called when the state changes, but we don't want to notify
/// the user if the state hasn't changed.
/// </summary>
/// <param name="rpcModel"></param>
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;

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp