From f5956e7bf07d03b73acf5d55256adf71ea19a2b7 Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:55:06 +0800 Subject: [PATCH] Improved await _updateView --- v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs | 6 +++--- v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs | 2 +- .../ViewModels/ClashConnectionsViewModel.cs | 2 +- .../ServiceLib/ViewModels/ClashProxiesViewModel.cs | 4 ++-- v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs | 2 +- v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs | 12 ++++++------ .../ServiceLib/ViewModels/OptionSettingViewModel.cs | 2 +- .../ViewModels/RoutingRuleDetailsViewModel.cs | 2 +- .../ViewModels/RoutingRuleSettingViewModel.cs | 2 +- .../ServiceLib/ViewModels/RoutingSettingViewModel.cs | 2 +- v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs | 2 +- 11 files changed, 19 insertions(+), 19 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs index 8124f268..beec1b8e 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServer2ViewModel.cs @@ -32,9 +32,9 @@ namespace ServiceLib.ViewModels } CoreType = SelectedSource?.coreType?.ToString(); - BrowseServerCmd = ReactiveCommand.CreateFromTask(async () => + BrowseServerCmd = ReactiveCommand.Create(() => { - await _updateView?.Invoke(EViewAction.BrowseServer, null); + _updateView?.Invoke(EViewAction.BrowseServer, null); }); EditServerCmd = ReactiveCommand.Create(() => @@ -67,7 +67,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0) { NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs index af26da9f..aa9d15fc 100644 --- a/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/AddServerViewModel.cs @@ -87,7 +87,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.AddServer(_config, SelectedSource) == 0) { NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs index 7016a43a..683fb0e4 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashConnectionsViewModel.cs @@ -109,7 +109,7 @@ namespace ServiceLib.ViewModels return; } - await _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections); + _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections); }); } diff --git a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs index 1f2f931a..d421d53f 100644 --- a/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/ClashProxiesViewModel.cs @@ -177,7 +177,7 @@ namespace ServiceLib.ViewModels } if (refreshUI) { - await _updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null); + _updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null); } }); } @@ -396,7 +396,7 @@ namespace ServiceLib.ViewModels return; } - await _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result }); + _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result }); }); } diff --git a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs index 13de1799..1fd5e390 100644 --- a/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/DNSSettingViewModel.cs @@ -106,7 +106,7 @@ namespace ServiceLib.ViewModels ConfigHandler.SaveDNSItems(_config, item2); NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs index b863e64f..63d47341 100644 --- a/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs @@ -433,7 +433,7 @@ namespace ServiceLib.ViewModels catch { } finally { - await _updateView?.Invoke(EViewAction.Shutdown, null); + _updateView?.Invoke(EViewAction.Shutdown, null); } } @@ -630,7 +630,7 @@ namespace ServiceLib.ViewModels await (new UpdateService()).RunAvailabilityCheck(async (bool success, string msg) => { NoticeHandler.Instance.SendMessageEx(msg); - await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); + _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg); }); } @@ -721,7 +721,7 @@ namespace ServiceLib.ViewModels { await TestServerAvailability(); - await _updateView?.Invoke(EViewAction.DispatcherReload, null); + _updateView?.Invoke(EViewAction.DispatcherReload, null); }); } @@ -781,7 +781,7 @@ namespace ServiceLib.ViewModels private async Task ChangeSystemProxyStatusAsync(ESysProxyType type, bool blChange) { //await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false); - await _updateView?.Invoke(EViewAction.UpdateSysProxy, false); + _updateView?.Invoke(EViewAction.UpdateSysProxy, false); NoticeHandler.Instance.SendMessageEx($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}"); BlSystemProxyClear = (type == ESysProxyType.ForcedClear); @@ -793,7 +793,7 @@ namespace ServiceLib.ViewModels if (blChange) { - await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); + _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); } } @@ -844,7 +844,7 @@ namespace ServiceLib.ViewModels { NoticeHandler.Instance.SendMessageEx(ResUI.TipChangeRouting); Reload(); - await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); + _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null); } } diff --git a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs index b7dd6a6d..cb658563 100644 --- a/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/OptionSettingViewModel.cs @@ -342,7 +342,7 @@ namespace ServiceLib.ViewModels { NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); } - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs index 5dc2971e..c00b176d 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleDetailsViewModel.cs @@ -87,7 +87,7 @@ namespace ServiceLib.ViewModels return; } //NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } } } \ No newline at end of file diff --git a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs index 5fa24745..4790df16 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingRuleSettingViewModel.cs @@ -240,7 +240,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SaveRoutingItem(_config, item) == 0) { NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs index fa1195df..e82db608 100644 --- a/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/RoutingSettingViewModel.cs @@ -200,7 +200,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.SaveConfig(_config) == 0) { NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } else { diff --git a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs index 31d3a171..79c1bb03 100644 --- a/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/SubEditViewModel.cs @@ -44,7 +44,7 @@ namespace ServiceLib.ViewModels if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0) { NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess); - await _updateView?.Invoke(EViewAction.CloseWindow, null); + _updateView?.Invoke(EViewAction.CloseWindow, null); } else {