mirror of
https://github.com/2dust/v2rayN.git
synced 2026-09-28 01:22:07 +03:00
Optimization and improvement, using event subscribers
This commit is contained in:
@@ -209,6 +209,26 @@ public class StatusBarViewModel : MyReactiveObject
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(async result => await UpdateStatistics(result));
|
||||
|
||||
AppEvents.RoutingsMenuRefreshRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(async _ => await RefreshRoutingsMenu());
|
||||
|
||||
AppEvents.TestServerRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(async _ => await TestServerAvailability());
|
||||
|
||||
AppEvents.InboundDisplayRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(async _ => await InboundDisplayStatus());
|
||||
|
||||
AppEvents.SysProxyChangeRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(async result => await SetListenerType(result));
|
||||
|
||||
#endregion AppEvents
|
||||
|
||||
_ = Init();
|
||||
@@ -329,7 +349,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||
{
|
||||
return;
|
||||
}
|
||||
AppEvents.SetDefaultServerRequested.OnNext(SelectedServer.ID);
|
||||
AppEvents.SetDefaultServerRequested.OnNext(SelectedServer.ID);
|
||||
}
|
||||
|
||||
public async Task TestServerAvailability()
|
||||
@@ -364,7 +384,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||
|
||||
#region System proxy and Routings
|
||||
|
||||
public async Task SetListenerType(ESysProxyType type)
|
||||
private async Task SetListenerType(ESysProxyType type)
|
||||
{
|
||||
if (_config.SystemProxyItem.SysProxyType == type)
|
||||
{
|
||||
@@ -393,7 +413,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||
}
|
||||
}
|
||||
|
||||
public async Task RefreshRoutingsMenu()
|
||||
private async Task RefreshRoutingsMenu()
|
||||
{
|
||||
RoutingItems.Clear();
|
||||
|
||||
@@ -501,7 +521,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||
|
||||
#region UI
|
||||
|
||||
public async Task InboundDisplayStatus()
|
||||
private async Task InboundDisplayStatus()
|
||||
{
|
||||
StringBuilder sb = new();
|
||||
sb.Append($"[{EInboundProtocol.mixed}:{AppManager.Instance.GetLocalPort(EInboundProtocol.socks)}");
|
||||
|
||||
Reference in New Issue
Block a user