Skip to content

Commit

Permalink
Optimize code and remove Action
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Feb 6, 2025
1 parent ba2a636 commit 67ffa81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions v2rayN/ServiceLib/Services/UpdateService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public async Task UpdateGeoFileAll(Config config, Action<bool, string> updateFun
_updateFunc?.Invoke(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo"));
}

public async Task RunAvailabilityCheck(Action<bool, string> updateFunc)
public async Task<string> RunAvailabilityCheck()
{
var downloadHandle = new DownloadService();
var time = await downloadHandle.RunAvailabilityCheck(null);
Expand All @@ -255,7 +255,7 @@ public async Task RunAvailabilityCheck(Action<bool, string> updateFunc)
ip = $"({ipInfo?.country_code}) {ipInfo?.ip}";
}

updateFunc?.Invoke(false, string.Format(ResUI.TestMeOutput, time, ip));
return string.Format(ResUI.TestMeOutput, time, ip);
}

#region CheckUpdate private
Expand Down
10 changes: 5 additions & 5 deletions v2rayN/ServiceLib/ViewModels/StatusBarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ public async Task TestServerAvailability()
{
return;
}
await (new UpdateService()).RunAvailabilityCheck(async (bool success, string msg) =>
{
NoticeHandler.Instance.SendMessageEx(msg);
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
});

var msg = await (new UpdateService()).RunAvailabilityCheck();

NoticeHandler.Instance.SendMessageEx(msg);
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
}

public void TestServerAvailabilityResult(string msg)
Expand Down

0 comments on commit 67ffa81

Please sign in to comment.