Skip to content

Commit

Permalink
Optimize the information function
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Sep 16, 2024
1 parent c4e01d2 commit 233d605
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
10 changes: 3 additions & 7 deletions v2rayN/ServiceLib/Handler/UpdateHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,10 @@ public async Task UpdateGeoFileAll(Config config, Action<bool, string> update)
_updateFunc(true, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, "geo"));
}

public void RunAvailabilityCheck(Action<bool, string> update)
public async Task RunAvailabilityCheck(Action<bool, string> update)
{
Task.Run(async () =>
{
var time = await (new DownloadHandler()).RunAvailabilityCheck(null);
update(false, string.Format(ResUI.TestMeOutput, time));
});
var time = await (new DownloadHandler()).RunAvailabilityCheck(null);
update(false, string.Format(ResUI.TestMeOutput, time));
}

#region private
Expand Down
15 changes: 3 additions & 12 deletions v2rayN/ServiceLib/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,6 @@ private void Init()

private void UpdateHandler(bool notify, string msg)
{
if (!_config.uiItem.showInTaskbar)
{
return;
}
_noticeHandler?.SendMessage(msg);
if (notify)
{
Expand Down Expand Up @@ -611,21 +607,16 @@ private void ServerSelectedChanged(bool c)
SetDefaultServer(SelectedServer.ID);
}

public void TestServerAvailability()
public async Task TestServerAvailability()
{
var item = ConfigHandler.GetDefaultServer(_config);
if (item == null)
{
return;
}
(new UpdateHandler()).RunAvailabilityCheck(async (bool success, string msg) =>
await (new UpdateHandler()).RunAvailabilityCheck(async (bool success, string msg) =>
{
_noticeHandler?.SendMessageEx(msg);
if (!_config.uiItem.showInTaskbar)
{
return;
}
await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
});
}
Expand Down Expand Up @@ -715,7 +706,7 @@ public void Reload()

LoadCore().ContinueWith(async task =>
{
TestServerAvailability();
await TestServerAvailability();
await _updateView?.Invoke(EViewAction.DispatcherReload, null);
});
Expand Down
4 changes: 4 additions & 0 deletions v2rayN/ServiceLib/ViewModels/MsgViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ private async Task AppendQueueMsg(string msg)
}

_blLockShow = true;
if (!_config.uiItem.showInTaskbar)
{
await Task.Delay(1000);
}

await Task.Delay(100);
var txt = string.Join("", _queueMsg.ToArray());
Expand Down

0 comments on commit 233d605

Please sign in to comment.