From 8be173071941e5cb70839d4612369ea7a9f1da2f Mon Sep 17 00:00:00 2001 From: 2dust <31833384+2dust@users.noreply.github.com> Date: Fri, 6 Sep 2024 09:40:45 +0800 Subject: [PATCH] Bug fix --- .../ViewModels/CheckUpdateViewModel.cs | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs index b1e3b798..48162b0b 100644 --- a/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs +++ b/v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs @@ -11,6 +11,7 @@ namespace ServiceLib.ViewModels public class CheckUpdateViewModel : MyReactiveObject { private const string _geo = "GeoFiles"; + private string _v2rayN = ECoreType.v2rayN.ToString(); private List _lstUpdated = []; private IObservableCollection _checkUpdateItem = new ObservableCollectionExtended(); @@ -52,7 +53,7 @@ namespace ServiceLib.ViewModels _checkUpdateItem.Add(new CheckUpdateItem() { isSelected = false, - coreType = ECoreType.v2rayN.ToString(), + coreType = _v2rayN, remarks = ResUI.menuCheckUpdate, }); _checkUpdateItem.Add(new CheckUpdateItem() @@ -98,7 +99,7 @@ namespace ServiceLib.ViewModels { await CheckUpdateGeo(); } - else if (item.coreType == ECoreType.v2rayN.ToString()) + else if (item.coreType == _v2rayN) { await CheckUpdateN(EnableCheckPreReleaseUpdate); } @@ -153,23 +154,23 @@ namespace ServiceLib.ViewModels && File.Exists(Path.Combine(Utils.StartupPath(), "D3DCompiler_47_cor3.dll")) ) { - UpdateView(ResUI.UpdateStandalonePackageTip, ResUI.UpdateStandalonePackageTip); + UpdateView(_v2rayN, ResUI.UpdateStandalonePackageTip); return; } void _updateUI(bool success, string msg) { - UpdateView(ECoreType.v2rayN.ToString(), msg); + UpdateView(_v2rayN, msg); if (success) { - UpdateView(ECoreType.v2rayN.ToString(), ResUI.OperationSuccess); - UpdatedPlusPlus(ECoreType.v2rayN.ToString(), msg); + UpdateView(_v2rayN, ResUI.OperationSuccess); + UpdatedPlusPlus(_v2rayN, msg); } } await (new UpdateHandler()).CheckUpdateGuiN(_config, _updateUI, preRelease) .ContinueWith(t => { - UpdatedPlusPlus(ECoreType.v2rayN.ToString(), ""); + UpdatedPlusPlus(_v2rayN, ""); }); } @@ -201,7 +202,7 @@ namespace ServiceLib.ViewModels Task.Delay(1000); UpgradeCore(); - if (_lstUpdated.Any(x => x.coreType == ECoreType.v2rayN.ToString() && x.isFinished == true)) + if (_lstUpdated.Any(x => x.coreType == _v2rayN && x.isFinished == true)) { Task.Delay(1000); UpgradeN(); @@ -228,7 +229,7 @@ namespace ServiceLib.ViewModels { try { - var fileName = _lstUpdated.FirstOrDefault(x => x.coreType == ECoreType.v2rayN.ToString())?.fileName; + var fileName = _lstUpdated.FirstOrDefault(x => x.coreType == _v2rayN)?.fileName; if (fileName.IsNullOrEmpty()) { return; @@ -251,7 +252,7 @@ namespace ServiceLib.ViewModels } catch (Exception ex) { - UpdateView(ECoreType.v2rayN.ToString(), ex.Message); + UpdateView(_v2rayN, ex.Message); } }