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

Commitefb60ca

Browse files
authored
chore: fixed user notifier default notification handler (#141)
1 parent7e3782f commitefb60ca

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

‎App/App.xaml.cs‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
namespaceCoder.Desktop.App;
2929

30-
publicpartialclassApp:Application,IDispatcherQueueManager,INotificationHandler
30+
publicpartialclassApp:Application,IDispatcherQueueManager,IDefaultNotificationHandler
3131
{
3232
privateconststringMutagenControllerConfigSection="MutagenController";
3333
privateconststringUpdaterConfigSection="Updater";
@@ -91,7 +91,7 @@ public App()
9191
services.AddSingleton<IAgentApiClientFactory,AgentApiClientFactory>();
9292

9393
services.AddSingleton<IDispatcherQueueManager>(_=>this);
94-
services.AddSingleton<INotificationHandler>(_=>this);
94+
services.AddSingleton<IDefaultNotificationHandler>(_=>this);
9595
services.AddSingleton<ICredentialBackend>(_=>
9696
newWindowsCredentialBackend(WindowsCredentialBackend.CoderCredentialsTargetName));
9797
services.AddSingleton<ICredentialManager,CredentialManager>();
@@ -337,12 +337,8 @@ public void RunInUiThread(DispatcherQueueHandler action)
337337
dispatcherQueue.TryEnqueue(action);
338338
}
339339

340-
publicvoidHandleNotificationActivation(IDictionary<string,string>args)
340+
publicvoidHandleNotificationActivation(IDictionary<string,string>_)
341341
{
342-
varapp=(App)Current;
343-
if(app!=null&&app.TrayWindow!=null)
344-
{
345-
app.TrayWindow.Tray_Open();
346-
}
342+
TrayWindow?.Tray_Open();
347343
}
348344
}

‎App/Services/UserNotifier.cs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ public interface INotificationHandler
1515
publicvoidHandleNotificationActivation(IDictionary<string,string>args);
1616
}
1717

18+
// This interface is meant to protect the default
19+
// notification handler from being overriden by DI.
20+
publicinterfaceIDefaultNotificationHandler:INotificationHandler
21+
{
22+
}
23+
1824
publicinterfaceIUserNotifier:INotificationHandler,IAsyncDisposable
1925
{
2026
publicvoidRegisterHandler(stringname,INotificationHandlerhandler);
@@ -46,7 +52,7 @@ public class UserNotifier : IUserNotifier
4652
privateConcurrentDictionary<string,INotificationHandler>Handlers{get;}=new();
4753

4854
publicUserNotifier(ILogger<UserNotifier>logger,IDispatcherQueueManagerdispatcherQueueManager,
49-
INotificationHandlernotificationHandler)
55+
IDefaultNotificationHandlernotificationHandler)
5056
{
5157
_logger=logger;
5258
_dispatcherQueueManager=dispatcherQueueManager;

‎App/Views/TrayWindow.xaml.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,13 @@ private void SetPageByState(RpcModel rpcModel, CredentialModel credentialModel,
152152
}
153153
}
154154

155+
/// <summary>
156+
/// This method is called when the state changes, but we don't want to notify
157+
/// the user if the state hasn't changed.
158+
/// </summary>
159+
/// <param name="rpcModel"></param>
155160
privatevoidMaybeNotifyUser(RpcModelrpcModel)
156161
{
157-
// This method is called when the state changes, but we don't want to notify
158-
// the user if the state hasn't changed.
159162
varisRpcLifecycleChanged=rpcModel.RpcLifecycle==RpcLifecycle.Disconnected&&curRpcLifecycle!=rpcModel.RpcLifecycle;
160163
varisVpnLifecycleChanged=(rpcModel.VpnLifecycle==VpnLifecycle.Started||rpcModel.VpnLifecycle==VpnLifecycle.Stopped)&&curVpnLifecycle!=rpcModel.VpnLifecycle;
161164

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp