Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Sep 6, 2024
1 parent 7ceaf5c commit 8be1730
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions v2rayN/ServiceLib/ViewModels/CheckUpdateViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace ServiceLib.ViewModels
public class CheckUpdateViewModel : MyReactiveObject
{
private const string _geo = "GeoFiles";
private string _v2rayN = ECoreType.v2rayN.ToString();
private List<CheckUpdateItem> _lstUpdated = [];

private IObservableCollection<CheckUpdateItem> _checkUpdateItem = new ObservableCollectionExtended<CheckUpdateItem>();
Expand Down Expand Up @@ -52,7 +53,7 @@ private void RefreshSubItems()
_checkUpdateItem.Add(new CheckUpdateItem()
{
isSelected = false,
coreType = ECoreType.v2rayN.ToString(),
coreType = _v2rayN,
remarks = ResUI.menuCheckUpdate,
});
_checkUpdateItem.Add(new CheckUpdateItem()
Expand Down Expand Up @@ -98,7 +99,7 @@ private async Task CheckUpdate()
{
await CheckUpdateGeo();
}
else if (item.coreType == ECoreType.v2rayN.ToString())
else if (item.coreType == _v2rayN)
{
await CheckUpdateN(EnableCheckPreReleaseUpdate);
}
Expand Down Expand Up @@ -153,23 +154,23 @@ private async Task CheckUpdateN(bool preRelease)
&& 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, "");
});
}

Expand Down Expand Up @@ -201,7 +202,7 @@ private void UpdateFinished()
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();
Expand All @@ -228,7 +229,7 @@ private void UpgradeN()
{
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;
Expand All @@ -251,7 +252,7 @@ private void UpgradeN()
}
catch (Exception ex)
{
UpdateView(ECoreType.v2rayN.ToString(), ex.Message);
UpdateView(_v2rayN, ex.Message);
}
}

Expand Down

0 comments on commit 8be1730

Please sign in to comment.